openrouterarchived avatar

Openrouter Typescript Sdk

Complete callModel-based reference for the OpenRouter TypeScript SDK, covering text generation, OAuth, and key management.

CCM score
46 of 100
skills.sh installs
2K
GitHub stars
29
last updated
Jul 14, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers installation, client setup, and the callModel pattern for accessing 300+ models through one interface
  • Includes API key management (apiKeys.list, create, get, update, delete) and an OAuth PKCE flow via createAuthCode and exchangeAuthCodeForAPIKey
  • Provides input formats for string prompts, multi-turn message arrays, and multimodal content, with streaming and tool execution noted as supported
  • Designed for server-side apps that need an API key and for user-facing apps that obtain per-user keys through OAuth

Install

$ npx -y skills add openrouterarchived/agent-skills --skill openrouter-typescript-sdk -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

OpenRouter TypeScript SDK

A comprehensive TypeScript SDK for interacting with OpenRouter's unified API, providing access to 300+ AI models through a single, type-safe interface. This skill enables AI agents to leverage the callModel pattern for text generation, tool usage, streaming, and multi-turn conversations.


Installation

npm install @openrouter/sdk

Setup

Get your API key from openrouter.ai/settings/keys, then initialize:

import OpenRouter from '@openrouter/sdk';

const client = new OpenRouter({
  apiKey: process.env.OPENROUTER_API_KEY
});

Authentication

The SDK supports two authentication methods: API keys for server-side applications and OAuth PKCE flow for user-facing applications.

API Key Authentication

The primary authentication method uses API keys from your OpenRouter account.

Obtaining an API Key
  1. Visit openrouter.ai/settings/keys
  2. Create a new API key
  3. Store securely in an environment variable
Environment Setup
export OPENROUTER_API_KEY=sk-or-v1-your-key-here
Client Initialization

Details

Repository
github.com/openrouterarchived/agent-skills
Categories
AI Agents & LLM Apps, Backend & APIs

More from openrouterarchived/agent-skills

All 2

Similar to Openrouter Typescript Sdk

More AI Agents & LLM Apps