TypeScript SDK
The TypeScript SDK and docs are currently in beta. Report issues on GitHub.
The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.
Why use the OpenRouter SDK?
Integrating AI models into applications involves handling different provider APIs, managing model-specific requirements, and avoiding common implementation mistakes. The OpenRouter SDK standardizes these integrations and protects you from footguns.
The SDK provides three core benefits:
Auto-generated from API specifications
The SDK is automatically generated from OpenRouter’s OpenAPI specs and updated with every API change. New models, parameters, and features appear in your IDE autocomplete immediately. No manual updates. No version drift.
Type-safe by default
Every parameter, response field, and configuration option is fully typed. Invalid configurations are caught at compile time, not in production.
Actionable error messages:
Type-safe streaming:
Installation
Get your API key from openrouter.ai/settings/keys.