Provider.Adapter for OpenRouter (https://openrouter.ai).
OpenRouter speaks an OpenAI-compatible wire format, so most of the work
is delegated to CouncilEx.Provider.Adapters.OpenAI. This wrapper
contributes the OpenRouter-specific concerns:
- Default
:base_urlofhttps://openrouter.ai/api/v1 - Optional
:refererand:titleconfig opts that map to theHTTP-Referer/X-Titleattribution headers (cost + leaderboard tracking on your OpenRouter dashboard) - Surfacing OpenRouter's
usage.costandusage.cost_detailsextras when present - OpenRouter-aware moduledoc for routing patterns (auto-router, fallback chains, model-variant suffixes)
Config
Application.put_env(:council_ex, :providers,
openrouter: [
adapter: CouncilEx.Provider.Adapters.OpenRouter,
api_key: {:system, "OPENROUTER_API_KEY"},
referer: "https://example.com", # optional
title: "MyApp" # optional
]
)Override :base_url if you front OpenRouter through a private gateway.
Models
Use OpenRouter's provider/model ID convention. Prefer undated GA IDs
(meta-llama/llama-3.3-70b-instruct, deepseek/deepseek-chat) over
date-suffixed ones, which shift on upstream updates. See
docs/PROVIDER_MODELS.md §5 for the catalog refresh protocol.
Routing patterns
model("openrouter/auto")— meta-model that routes to one of ~19 top models based on prompt complexity. Pay the selected model's rate.model("openrouter/free")— routes to free-tier models matching the request's feature requirements.- Append a variant suffix to any model ID:
:nitro— max throughput:floor— lowest price:online— injects live web-search results:thinking— forces extended reasoning:free— free-tier (20 RPM)
- For richer routing (provider preferences, fallback chains, plugins),
use OpenRouter's
provider/models/route/pluginsbody keys — add them via your own request-shaping if needed.