Skip to main content
Factory function to create an OpenRouter model instance. OpenRouter provides access to many AI models through a unified OpenAI-compatible API.

Signature

Parameters

str
required
The model identifier in provider/model-name format (e.g., “openai/gpt-4o”).
str
OpenRouter API key. Falls back to OPENROUTER_API_KEY environment variable.

Returns

A LanguageModel instance configured for OpenRouter.

Environment

Requires OPENROUTER_API_KEY environment variable.

Example

Provider Options