Skip to content

OpenRouter

Provider value: openai-completions

OpenRouter gives you access to hundreds of models from many providers through a single API. It uses an OpenAI-compatible endpoint, so ra connects via the openai-completions provider.

Quick start

bash
export OPENAI_API_KEY=sk-or-...   # your OpenRouter API key
ra --provider openai-completions \
  --openai-base-url https://openrouter.ai/api/v1 \
  --model anthropic/claude-sonnet-4 "Hello"

Config file

yaml
app:
  providers:
    openai-completions:
      baseURL: https://openrouter.ai/api/v1
      apiKey: ${OPENROUTER_API_KEY}

agent:
  provider: openai-completions
  model: anthropic/claude-sonnet-4

OpenRouter hosts models from many providers. A few examples:

ModelModel ID
Claude Sonnetanthropic/claude-sonnet-4
GPT-4.1openai/gpt-4.1
Gemini 2.5 Progoogle/gemini-2.5-pro
Llama 3 70Bmeta-llama/llama-3-70b-instruct
DeepSeek R1deepseek/deepseek-r1

See the full list at openrouter.ai/models.

Environment variables

VariableRequiredDescription
OPENROUTER_API_KEYYesYour OpenRouter API key (set as OPENAI_API_KEY or in config)

TIP

OpenRouter uses the same apiKey field as other OpenAI-compatible services. You can either set OPENAI_API_KEY to your OpenRouter key, or use a separate OPENROUTER_API_KEY variable and reference it in your config file.

See also

Released under the MIT License.