openrouterteam avatar

Openrouter Typescript Sdk

If you need to hit multiple AI models without writing separate integrations for each provider, this SDK gives you one interface for 300+ models through OpenRouter. The callModel pattern handles the usual stuff: streaming, tool calls, multi-turn conversations with automatic tool execution. The tool system uses Zod schemas and lets you modify parameters between turns via nextTurnParams, which is handy for adaptive workflows. You also get cost controls and stop conditions to prevent runaway multi-turn loops. Worth noting it includes OAuth PKCE flow support if you're building user-facing apps rather than just internal tooling. Solid choice when you want model flexibility without maintaining a dozen different client libraries.

skills.sh installs
2K
GitHub stars
29
last updated
Jul 14, 2026

Install

$ npx -y skills add openrouterteam/agent-skills --skill openrouter-typescript-sdk --agent claude-code

Installs into .claude/skills of the current project.

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

Sponsors

Details

Repository
github.com/openrouterteam/agent-skills
Category
AI & Agent Building

More from openrouterteam/agent-skills

All 2
1k-dense-ai avatarqiskitk-dense-ai/scientific-agent-skillsBuild, simulate, transpile, and execute quantum circuits with Qiskit and IBM Quantum Runtime. Use for Qiskit 2.x circuits and operators, V2 Sampler or Estimator2Kskills.sh installs
2k-dense-ai avatargtarsk-dense-ai/scientific-agent-skillsUse Gtars for local genomic interval models and set algebra, overlaps and counts, consensus and coverage, tokenization, fragment processing, and refget/BEDbase 2Kskills.sh installs
3k-dense-ai avatarmatchmsk-dense-ai/scientific-agent-skillsProcess, clean, compare, and search tandem mass spectra with matchms. Use for MS/MS file I/O, metadata harmonization, peak filtering, spectral similarity, libra2Kskills.sh installs
4k-dense-ai avatarhistolabk-dense-ai/scientific-agent-skillsLightweight WSI tile extraction and preprocessing. Use for basic slide processing, tissue detection, tile extraction, and stain normalization for H&E images. Be2Kskills.sh installs
5k-dense-ai avatarpolars-biok-dense-ai/scientific-agent-skillsHigh-performance genomic interval operations and bioinformatics file I/O on Polars DataFrames. Overlap, nearest, merge, coverage, complement, subtract for BED/V2Kskills.sh installs
6kotlin avatarkotlin-tooling-cocoapods-spm-migrationkotlin/kotlin-agent-skillsMigrate KMP projects from CocoaPods (kotlin("native.cocoapods")) to Swift Package Manager (swiftPMDependencies DSL) — replaces pod() with swiftPackage(), transf2Kskills.sh installs