For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
  • Python SDK
    • Overview
  • Go SDK
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Install instructions
  • When to use the Client SDKs
  • Quick example
  • Client SDKs vs Agent SDK
  • Next steps

Client SDKs

Lightweight, type-safe clients for the OpenRouter API

Was this page helpful?

Usage for Agents

Add OpenRouter Client SDKs skills to your AI coding assistant
Next
Built with

The Client SDKs give you a thin, type-safe layer over the OpenRouter REST API. It handles authentication, request validation, and response typing so you can call any of 300+ models with a single function call — no boilerplate, no provider-specific quirks.

Install instructions

LanguagePackageInstall
TypeScript@openrouter/sdknpm install @openrouter/sdk
Pythonopenrouterpip install openrouter
Gogo-sdkgo get github.com/OpenRouterTeam/go-sdk

All three SDKs are auto-generated from the OpenRouter OpenAPI spec, so new models, parameters, and endpoints appear immediately after each API release.

When to use the Client SDKs

Choose the Client SDKs when you need direct, efficient access to model inference and want to manage your own application logic:

  • Single-turn completions — send a prompt, get a response
  • Streaming responses — real-time token-by-token output
  • Embeddings, video, and rerank — generate vector representations, create videos, and rerank results
  • API key and credit management — programmatic control over your account
  • Custom orchestration — you handle conversation loops, tool dispatch, and state yourself

The Client SDKs are intentionally lean. It mirrors the OpenRouter API surface 1:1 with full type safety, so there is no abstraction to fight when you need fine-grained control.

If you want higher-level primitives for building agents — multi-turn loops, tool definitions, stop conditions, and conversation state management — see the Agent SDK instead.

Quick example

1import OpenRouter from '@openrouter/sdk';
2
3const client = new OpenRouter({
4 apiKey: process.env.OPENROUTER_API_KEY,
5});
6
7const response = await client.chat.send({
8 model: 'openai/gpt-5.2',
9 messages: [
10 { role: 'user', content: 'Explain quantum computing in one sentence.' },
11 ],
12});
13
14console.log(response.choices[0].message.content);

Client SDKs vs Agent SDK

Client SDKsAgent SDK
FocusLean API client — mirrors the REST API with full type safetyAgentic primitives — multi-turn loops, tools, stop conditions
Use whenYou want direct model calls and manage orchestration yourselfYou want built-in agent loops, tool execution, and state management
Conversation stateYou manage itManaged for you via callModel
Tool executionYou dispatch tool callsAutomatic with the tool() helper
LanguagesTypeScript, Python, GoTypeScript

Next steps

  • TypeScript SDK reference
  • Python SDK reference
  • Go SDK reference
  • Agent SDK overview — for building agents with multi-turn loops and tools