OpenRouter
OpenRouter routes requests to hundreds of models from many labs behind a single API and API key.
Installation
Section titled “Installation”The OpenAI provider is an optional dependency. To install, run:
pip install 'strands-agents[openai]'npm install @strands-agents/sdk openaiCreate an API key, export it as
OPENROUTER_API_KEY, and point the provider at OpenRouter’s endpoint:
import os
from strands import Agentfrom strands.models.openai import OpenAIModel
model = OpenAIModel( client_args={ "api_key": os.environ["OPENROUTER_API_KEY"], "base_url": "https://openrouter.ai/api/v1", }, model_id="openai/gpt-5.4",)
agent = Agent(model=model)response = agent("Explain tool calling in one sentence.")print(response)import { Agent } from '@strands-agents/sdk'import { OpenAIModel } from '@strands-agents/sdk/models/openai'
const model = new OpenAIModel({ api: 'chat', apiKey: process.env.OPENROUTER_API_KEY, clientConfig: { baseURL: 'https://openrouter.ai/api/v1', }, modelId: 'openai/gpt-5.4',})
const agent = new Agent({ model })const response = await agent.invoke('Explain tool calling in one sentence.')console.log(response)Configuration
Section titled “Configuration”Two client settings connect the provider to OpenRouter:
- API key: from your OpenRouter settings
- Base URL:
https://openrouter.ai/api/v1
Model IDs come from the OpenRouter catalog and are
prefixed with the lab name, for example openai/gpt-5.4 or
anthropic/claude-sonnet-4-5. For model parameters and other provider options, see
the OpenAI provider guide.