Agent SDK for TypeScript and Python with 400+ models. Streaming, tool calling, and multi-turn agent workflows built in.
Get started in minutes. TypeScript and Python SDKs available now.
import { OpenRouter } from '@openrouter/agent';
const openrouter = new OpenRouter();
const result = openrouter.callModel({
model: 'anthropic/claude-sonnet-4',
input: 'Explain quantum computing in simple terms.',
});
const text = await result.getText();
console.log(text);Build AI agents with type-safe tools, multi-turn execution, and stop conditions. Install @openrouter/agent and start building autonomous workflows.
import { OpenRouter, tool, stepCountIs } from '@openrouter/agent';
import { z } from 'zod';
const openrouter = new OpenRouter();
const searchTool = tool({
name: 'search',
description: 'Search the web for information',
inputSchema: z.object({
query: z.string(),
}),
execute: async ({ query }) => {
return { results: ['Result 1', 'Result 2'] };
},
});
const result = openrouter.callModel({
model: 'anthropic/claude-sonnet-4',
input: 'Research the latest advances in fusion energy.',
tools: [searchTool],
stopWhen: stepCountIs(5),
});
for await (const delta of result.getTextStream()) {
process.stdout.write(delta);
}For chat completion primitives without the agent toolkit, install @openrouter/sdk directly. Auto-generated from the OpenAPI spec with full type safety.
npm i @openrouter/sdk
import { OpenRouter } from '@openrouter/sdk';
const client = new OpenRouter();
const response = await client.chat.send({
model: 'anthropic/claude-sonnet-4',
messages: [
{ role: 'user', content: 'Explain quantum computing in simple terms.' }
],
});
console.log(response.choices[0].message.content);Add the SDK to your project. TypeScript and Python available today.
Access 400+ models through one interface. Stream, extract, or batch results.
Go from prototype to production. The same API works at any scale.