# ![OpenRouter logo](https://models.dev/logos/openrouter.svg)OpenRouter

OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 171 models through Mastra's model router.

Learn more in the [OpenRouter documentation](https://openrouter.ai/models).

## Usage

```typescript
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
  id: "my-agent",
  name: "My Agent",
  instructions: "You are a helpful assistant",
  model: "openrouter/anthropic/claude-3.5-haiku"
});
```

> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [OpenRouter documentation](https://openrouter.ai/models) for details.

## Configuration

```bash
# Use gateway API key
OPENROUTER_API_KEY=your-gateway-key

# Or use provider API keys directly
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=ant-...
```

## Available models

| Model                                                           |
| --------------------------------------------------------------- |
| `anthropic/claude-3.5-haiku`                                    |
| `anthropic/claude-3.7-sonnet`                                   |
| `anthropic/claude-haiku-4.5`                                    |
| `anthropic/claude-opus-4`                                       |
| `anthropic/claude-opus-4.1`                                     |
| `anthropic/claude-opus-4.5`                                     |
| `anthropic/claude-opus-4.6`                                     |
| `anthropic/claude-sonnet-4`                                     |
| `anthropic/claude-sonnet-4.5`                                   |
| `anthropic/claude-sonnet-4.6`                                   |
| `arcee-ai/trinity-large-preview:free`                           |
| `arcee-ai/trinity-large-thinking`                               |
| `arcee-ai/trinity-mini:free`                                    |
| `black-forest-labs/flux.2-flex`                                 |
| `black-forest-labs/flux.2-klein-4b`                             |
| `black-forest-labs/flux.2-max`                                  |
| `black-forest-labs/flux.2-pro`                                  |
| `bytedance-seed/seedream-4.5`                                   |
| `cognitivecomputations/dolphin-mistral-24b-venice-edition:free` |
| `deepseek/deepseek-chat-v3-0324`                                |
| `deepseek/deepseek-chat-v3.1`                                   |
| `deepseek/deepseek-r1-distill-llama-70b`                        |
| `deepseek/deepseek-v3.1-terminus`                               |
| `deepseek/deepseek-v3.1-terminus:exacto`                        |
| `deepseek/deepseek-v3.2`                                        |
| `deepseek/deepseek-v3.2-speciale`                               |
| `google/gemini-2.0-flash-001`                                   |
| `google/gemini-2.5-flash`                                       |
| `google/gemini-2.5-flash-lite`                                  |
| `google/gemini-2.5-flash-lite-preview-09-2025`                  |
| `google/gemini-2.5-flash-preview-09-2025`                       |
| `google/gemini-2.5-pro`                                         |
| `google/gemini-2.5-pro-preview-05-06`                           |
| `google/gemini-2.5-pro-preview-06-05`                           |
| `google/gemini-3-flash-preview`                                 |
| `google/gemini-3-pro-preview`                                   |
| `google/gemini-3.1-flash-lite-preview`                          |
| `google/gemini-3.1-pro-preview`                                 |
| `google/gemini-3.1-pro-preview-customtools`                     |
| `google/gemma-2-9b-it`                                          |
| `google/gemma-3-12b-it`                                         |
| `google/gemma-3-12b-it:free`                                    |
| `google/gemma-3-27b-it`                                         |
| `google/gemma-3-27b-it:free`                                    |
| `google/gemma-3-4b-it`                                          |
| `google/gemma-3-4b-it:free`                                     |
| `google/gemma-3n-e2b-it:free`                                   |
| `google/gemma-3n-e4b-it`                                        |
| `google/gemma-3n-e4b-it:free`                                   |
| `google/gemma-4-26b-a4b-it`                                     |
| `google/gemma-4-31b-it`                                         |
| `inception/mercury`                                             |
| `inception/mercury-2`                                           |
| `inception/mercury-coder`                                       |
| `liquid/lfm-2.5-1.2b-instruct:free`                             |
| `liquid/lfm-2.5-1.2b-thinking:free`                             |
| `meta-llama/llama-3.2-11b-vision-instruct`                      |
| `meta-llama/llama-3.2-3b-instruct:free`                         |
| `meta-llama/llama-3.3-70b-instruct:free`                        |
| `minimax/minimax-01`                                            |
| `minimax/minimax-m1`                                            |
| `minimax/minimax-m2`                                            |
| `minimax/minimax-m2.1`                                          |
| `minimax/minimax-m2.5`                                          |
| `minimax/minimax-m2.7`                                          |
| `mistralai/codestral-2508`                                      |
| `mistralai/devstral-2512`                                       |
| `mistralai/devstral-medium-2507`                                |
| `mistralai/devstral-small-2505`                                 |
| `mistralai/devstral-small-2507`                                 |
| `mistralai/mistral-medium-3`                                    |
| `mistralai/mistral-medium-3.1`                                  |
| `mistralai/mistral-small-2603`                                  |
| `mistralai/mistral-small-3.1-24b-instruct`                      |
| `mistralai/mistral-small-3.2-24b-instruct`                      |
| `moonshotai/kimi-k2`                                            |
| `moonshotai/kimi-k2-0905`                                       |
| `moonshotai/kimi-k2-0905:exacto`                                |
| `moonshotai/kimi-k2-thinking`                                   |
| `moonshotai/kimi-k2:free`                                       |
| `moonshotai/kimi-k2.5`                                          |
| `nousresearch/hermes-3-llama-3.1-405b:free`                     |
| `nousresearch/hermes-4-405b`                                    |
| `nousresearch/hermes-4-70b`                                     |
| `nvidia/nemotron-3-nano-30b-a3b:free`                           |
| `nvidia/nemotron-3-super-120b-a12b`                             |
| `nvidia/nemotron-3-super-120b-a12b:free`                        |
| `nvidia/nemotron-nano-12b-v2-vl:free`                           |
| `nvidia/nemotron-nano-9b-v2`                                    |
| `nvidia/nemotron-nano-9b-v2:free`                               |
| `openai/gpt-4.1`                                                |
| `openai/gpt-4.1-mini`                                           |
| `openai/gpt-4o-mini`                                            |
| `openai/gpt-5`                                                  |
| `openai/gpt-5-chat`                                             |
| `openai/gpt-5-codex`                                            |
| `openai/gpt-5-image`                                            |
| `openai/gpt-5-mini`                                             |
| `openai/gpt-5-nano`                                             |
| `openai/gpt-5-pro`                                              |
| `openai/gpt-5.1`                                                |
| `openai/gpt-5.1-chat`                                           |
| `openai/gpt-5.1-codex`                                          |
| `openai/gpt-5.1-codex-max`                                      |
| `openai/gpt-5.1-codex-mini`                                     |
| `openai/gpt-5.2`                                                |
| `openai/gpt-5.2-chat`                                           |
| `openai/gpt-5.2-codex`                                          |
| `openai/gpt-5.2-pro`                                            |
| `openai/gpt-5.3-codex`                                          |
| `openai/gpt-5.4`                                                |
| `openai/gpt-5.4-mini`                                           |
| `openai/gpt-5.4-nano`                                           |
| `openai/gpt-5.4-pro`                                            |
| `openai/gpt-oss-120b`                                           |
| `openai/gpt-oss-120b:exacto`                                    |
| `openai/gpt-oss-120b:free`                                      |
| `openai/gpt-oss-20b`                                            |
| `openai/gpt-oss-20b:free`                                       |
| `openai/gpt-oss-safeguard-20b`                                  |
| `openai/o4-mini`                                                |
| `openrouter/free`                                               |
| `prime-intellect/intellect-3`                                   |
| `qwen/qwen-2.5-coder-32b-instruct`                              |
| `qwen/qwen2.5-vl-72b-instruct`                                  |
| `qwen/qwen3-235b-a22b-07-25`                                    |
| `qwen/qwen3-235b-a22b-thinking-2507`                            |
| `qwen/qwen3-30b-a3b-instruct-2507`                              |
| `qwen/qwen3-30b-a3b-thinking-2507`                              |
| `qwen/qwen3-4b:free`                                            |
| `qwen/qwen3-coder`                                              |
| `qwen/qwen3-coder-30b-a3b-instruct`                             |
| `qwen/qwen3-coder-flash`                                        |
| `qwen/qwen3-coder:exacto`                                       |
| `qwen/qwen3-coder:free`                                         |
| `qwen/qwen3-max`                                                |
| `qwen/qwen3-next-80b-a3b-instruct`                              |
| `qwen/qwen3-next-80b-a3b-instruct:free`                         |
| `qwen/qwen3-next-80b-a3b-thinking`                              |
| `qwen/qwen3.5-397b-a17b`                                        |
| `qwen/qwen3.5-plus-02-15`                                       |
| `qwen/qwen3.6-plus:free`                                        |
| `sourceful/riverflow-v2-fast-preview`                           |
| `sourceful/riverflow-v2-max-preview`                            |
| `sourceful/riverflow-v2-standard-preview`                       |
| `stepfun/step-3.5-flash`                                        |
| `stepfun/step-3.5-flash:free`                                   |
| `x-ai/grok-3`                                                   |
| `x-ai/grok-3-beta`                                              |
| `x-ai/grok-3-mini`                                              |
| `x-ai/grok-3-mini-beta`                                         |
| `x-ai/grok-4`                                                   |
| `x-ai/grok-4-fast`                                              |
| `x-ai/grok-4.1-fast`                                            |
| `x-ai/grok-4.20-beta`                                           |
| `x-ai/grok-4.20-multi-agent-beta`                               |
| `x-ai/grok-code-fast-1`                                         |
| `xiaomi/mimo-v2-flash`                                          |
| `xiaomi/mimo-v2-omni`                                           |
| `xiaomi/mimo-v2-pro`                                            |
| `z-ai/glm-4.5`                                                  |
| `z-ai/glm-4.5-air`                                              |
| `z-ai/glm-4.5-air:free`                                         |
| `z-ai/glm-4.5v`                                                 |
| `z-ai/glm-4.6`                                                  |
| `z-ai/glm-4.6:exacto`                                           |
| `z-ai/glm-4.7`                                                  |
| `z-ai/glm-4.7-flash`                                            |
| `z-ai/glm-5`                                                    |
| `z-ai/glm-5-turbo`                                              |
| `z-ai/glm-5.1`                                                  |