OpenRouter is a unified API that provides access to multiple AI models from different providers (OpenAI, Anthropic, Google, Meta, and more) through a single endpoint.
OpenRouter uses API key authentication. Get your API key from OpenRouter Settings.
Set the OPENROUTER_API_KEY environment variable:
export OPENROUTER_API_KEY="sk-or-v1-..."You can also configure the API key in CodexBar Settings → Providers → OpenRouter.
The OpenRouter provider fetches usage data from two API endpoints:
-
Credits API (
/api/v1/credits): Returns total credits purchased and total usage. The balance is calculated astotal_credits - total_usage. -
Key API (
/api/v1/key): Returns rate limit information for your API key.
The OpenRouter menu card shows:
- Primary meter: Credit usage percentage (how much of your purchased credits have been used)
- Balance: Displayed in the identity section as "Balance: $X.XX"
codexbar --provider openrouter
codexbar -p or # alias| Variable | Description |
|---|---|
OPENROUTER_API_KEY |
Your OpenRouter API key (required) |
OPENROUTER_API_URL |
Override the base API URL (optional, defaults to https://openrouter.ai/api/v1) |
OPENROUTER_HTTP_REFERER |
Optional client referer sent as HTTP-Referer header |
OPENROUTER_X_TITLE |
Optional client title sent as X-Title header (defaults to CodexBar) |
- Credit values are cached on OpenRouter's side and may be up to 60 seconds stale
- OpenRouter uses a credit-based billing system where you pre-purchase credits
- Rate limits depend on your credit balance (10+ credits = 1000 free model requests/day)