openrouter-typescript-sdk

Installation
Summary

Type-safe TypeScript SDK for accessing 300+ AI models through OpenRouter's unified API.

  • Provides the callModel pattern for text generation, tool usage, streaming, and multi-turn conversations with automatic tool execution
  • Supports flexible input formats: strings, message arrays, multimodal content with images, and system instructions
  • Includes a strongly-typed tool system using Zod schemas with regular, generator, and manual tool modes; tools can modify parameters for subsequent turns via nextTurnParams
  • Offers multiple response consumption methods: getText(), getResponse(), getTextStream(), getReasoningStream(), and getToolCallsStream() with concurrent consumer support
  • Provides OAuth PKCE flow for user-facing applications and API key management, plus stop conditions (stepCountIs, maxCost, hasToolCall) to control multi-turn execution and costs
SKILL.md

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';
Related skills
Installs
1.8K
GitHub Stars
26
First Seen
Jan 19, 2026