Quickstart
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:
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 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.