Skip to main content
OpenRouter provides a unified API that gives you access to hundreds of AI models through a single endpoint, while automatically handling fallbacks and selecting the most cost-effective options. There are three ways to integrate with OpenRouter, depending on how much control you want:
ApproachBest for
APIFull control, any language, no dependencies
Client SDKsType-safe model calls with minimal overhead
Agent SDKBuilding agents with tool use, loops, and state
Looking for information about free models and rate limits? Please see the FAQ
In the examples below, the OpenRouter-specific headers are optional. Setting them allows your app to appear on the OpenRouter leaderboards. For detailed information about app attribution, see our App Attribution guide.

Using the OpenRouter API

The most direct way to use OpenRouter. Send standard HTTP requests to the /api/v1/chat/completions endpoint — compatible with any language or framework.
You can use the interactive Request Builder to generate OpenRouter API requests in the language of your choice.
The examples below use ~openai/gpt-latest, a latest alias that always resolves to the newest OpenAI flagship model — so your code keeps using the freshest version without redeploying. You can substitute any model slug here. Browse the full catalog at openrouter.ai/models, or list every available slug programmatically via the GET /api/v1/models endpoint.
The API also supports streaming. You can also use the OpenAI SDK pointed at OpenRouter as a drop-in replacement.

Using the Client SDKs

The Client SDKs wrap the OpenRouter API with full type safety, auto-generated types from the OpenAPI spec, and zero boilerplate. It is intentionally lean — a thin layer over the REST API. First, install the SDK:
Then use it in your code:
See the full Client SDKs documentation for streaming, embeddings, and the complete API reference.

Using the Agent SDK

The Agent SDK (@openrouter/agent) provides higher-level primitives for building AI agents. It handles multi-turn conversation loops, tool execution, and state management automatically via the callModel function. Install the package:
Build an agent with tools:
The SDK sends the prompt, receives a tool call from the model, executes get_weather, feeds the result back, and returns the final response — all in one callModel invocation. See the full Agent SDK documentation for stop conditions, streaming, dynamic parameters, and more.

Using the OpenAI SDK

You can also use the OpenAI SDK pointed at OpenRouter as a drop-in replacement. This is useful if you have existing code built on the OpenAI SDK and want to access OpenRouter’s model catalog without changing your code structure.

Using third-party SDKs

For information about using third-party SDKs and frameworks with OpenRouter, please see our frameworks documentation.

Building with an AI assistant

If you write code with an AI coding tool (Claude Code, Cursor, Codex, and others), connect the OpenRouter MCP server. It’s a remote server hosted by OpenRouter — nothing to install — that lets your assistant pull live OpenRouter data (which models exist, what they cost, your credit balance, usage rankings) and search these docs while you build, so its suggestions reflect current data instead of stale training knowledge. Add one URL to your MCP client and approve an OAuth login:
See the MCP server guide for per-client setup and the full tool list. To run models in your app, keep calling the OpenRouter API directly.