Skip to content
OpenRouterOpenRouter
© 2026 OpenRouter, Inc

Product

  • Chat
  • Rankings
  • Apps
  • Models
  • Providers
  • Pricing
  • Enterprise
  • Labs

Company

  • About
  • Blog
  • Careers
    Hiring
  • Privacy
  • Terms of Service
  • Support
  • State of AI
  • Works With OR
  • Data

Developer

  • Documentation
  • API Reference
  • SDK
  • Status

Connect

  • Discord
  • GitHub
  • LinkedIn
  • X
  • YouTube

The Model-Agnostic Agent SDK

Agent SDK for TypeScript and Python with 400+ models. Streaming, tool calling, and multi-turn agent workflows built in.

Get API KeyView Docs
Flexible Results
Stream, extract, and process the same response concurrently. No need to choose upfront.
Built-In Streaming
Streaming works out of the box. Custom events and transforms without the boilerplate.
Isolated Tools
Tools run separately from model calls. Clean boundaries, no tangled logic.
Agentic Workflows
Tools can modify the next request. Build complex agents as small, testable pieces.
Scales Linearly
Lightweight and modular. Small API that grows with you, no rewrites required.
Drop-In Ready
Works with existing AI SDKs. Migrate incrementally with full type safety.

Simple, Powerful API

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);

Agent SDK for TypeScript

Build AI agents with type-safe tools, multi-turn execution, and stop conditions. Install @openrouter/agent and start building autonomous workflows.

callModel API
One function to call any model. Get text, stream responses, or extract structured data from a single call.
Type-Safe Tools
Define tools with Zod schemas and automatic execution. Full TypeScript inference for inputs, outputs, and events.
Multi-Turn Agents
Build agentic loops with automatic tool execution. Tools can modify the next request for complex workflows.
Stop Conditions
Control agent execution with built-in helpers: stop by step count, tool calls, cost limits, or custom logic.
Tool Approval
Add human-in-the-loop approval gates before tool execution for safe, controlled agent behavior.
CLI Integration
Works with AI coding assistants like Claude Code, Cursor, and Copilot via installable agent skills.

Build an Agent in Minutes

typescript
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);
}

Chat Completions with the Client SDKs

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);
1

Install

Add the SDK to your project. TypeScript and Python available today.

2

Call Any Model

Access 400+ models through one interface. Stream, extract, or batch results.

3

Ship & Scale

Go from prototype to production. The same API works at any scale.

Start Building Today

Get your API key and ship your first AI feature in minutes.

Get API KeyView Docs