OpenRouter Agent SDK

AI model by OpenRouter

Build production AI agents with type-safe tools and multi-turn loops across 600+ models.

A development framework for building autonomous AI agents with type-safe tools and multi-turn loops. It enables developers to orchestrate 600+ models through a single callModel function that handles state and tool execution automatically.

Model specs

The full spec card (context, pricing per token, modalities and more) on AntSpace. Sign up free to see the full spec card.

Languages
TypeScript

Category: AI Agents

Sizes and variants
Compatible with 600+ models on OpenRouter
Access
NPM package (@openrouter/agent), GitHub repository
Released
Active since at least 2026-11-12
Package Name
@openrouter/agent
Supported Languages
TypeScript, Python, Go
Primary Function
callModel
  • Type-safe tools and multi-turn loops
  • Automated state management via callModel
  • Supports 600+ models across 80+ providers
  • Available for TypeScript, Python (Beta), and Go (Beta)

Overview

OpenRouter Agent SDK is a specialized development framework designed for building autonomous AI agents that interact with tools and maintain state across multiple turns. It provides software engineers with higher-level primitives such as type-safe tools, multi-turn loops, and automated state management through a single callModel function. By abstracting the complexities of manual tool orchestration, the SDK enables the creation of production-ready agents that can route across 600+ models and 80+ providers. It is primarily delivered as an NPM package for TypeScript and JavaScript, with beta versions available for Python and Go. The SDK integrates with OpenRouter's unified API to provide automatic fallbacks and cost-effective routing for agentic workflows.

Agent Orchestration

  • Agentic Primitives: The SDK provides higher-level primitives for building AI agents, including tool use, multi-turn conversation loops, and state management.
  • Automated Tool Execution: The callModel function handles the entire loop of sending prompts, receiving tool calls, executing them, and feeding results back to the model automatically.
  • Execution Control: Developers can define stop conditions, such as stepCountIs, to control the duration and depth of agentic reasoning loops.
  • Provider Agnostic Routing: The framework enables building production agents that can route across every provider in the OpenRouter marketplace.

Developer Experience

  • TypeScript/JavaScript Support: The SDK is available as a TypeScript package installable via npm, pnpm, yarn, bun, or deno.
  • Python SDK (Beta): A Python version of the Agent SDK is available in beta for developers working in Python environments.
  • Go SDK (Beta): A Go version of the Agent SDK is currently in beta for building agents in the Go programming language.
  • Type-Safe Tools: The SDK uses Zod for type-safe tool definitions and input schema validation.

Use cases

  • Developers build autonomous agents that use tools like weather APIs or search engines to answer complex queries.
  • Engineering teams create multi-turn conversation loops that maintain state without manual API orchestration.
  • Software architects implement agentic workflows that automatically fallback across different model providers to ensure uptime.

Specifications

Sizes and variants
Compatible with 600+ models on OpenRouter
Access
NPM package (@openrouter/agent), GitHub repository
Released
Active since at least 2026-11-12
Package Name
@openrouter/agent
Supported Languages
TypeScript, Python, Go
Primary Function
callModel
Tool Schema Library
Zod
Integration MethodBase
NPM / Yarn / Pnpm / Bun / Deno / Pip

How it works

  1. Install the SDK: Install the package using npm i @openrouter/agent or the equivalent for your package manager.
  2. Define Agent Tools: Define tools using the tool function and specify input schemas with Zod for type safety.
  3. Execute Agentic Loops: Use the callModel function to initiate an agentic loop that handles tool calls and responses automatically.

FAQ

When should I use the Agent SDK instead of the Client SDK?

The Agent SDK is best for building agents that require tool use, multi-turn loops, and automated state management.

How does the Agent SDK handle tool execution?

The SDK uses the callModel function to handle multi-turn conversation loops and tool execution automatically.

What languages does the Agent SDK support?

Yes, the Agent SDK is available for TypeScript, and has beta support for Python and Go.

Read the docs

Added by AntSpace from public sources (openrouter.ai).

Related

More AI models by OpenRouter