OpenClaude Router keeps the Claude Code agent/tool runtime, but routes model traffic through an OpenRouter-first OpenAI-compatible shim.
export CLAUDE_CODE_USE_OPENAI=1
export OPENROUTER_API_KEY=sk-or-...
export OPENROUTER_MODEL=openai/gpt-4o-mini
# optional
export OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
export OPENROUTER_STREAM=auto # auto|on|off
export OPENROUTER_MODELS=openai/gpt-4o-mini,google/gemini-2.5-flash
openclaudeCompatibility aliases supported in this PR:
OPENAI_API_KEY→OPENROUTER_API_KEYOPENAI_BASE_URL→OPENROUTER_BASE_URLOPENAI_MODEL→OPENROUTER_MODEL
Set OPENROUTER_PROFILE or use launcher scripts:
free(opt-in only; never default for autonomous coding)balancedreliablecheap
Commands:
bun run dev:openrouter
bun run dev:free
bun run dev:cheap
bun run dev:reliable- If selected model metadata indicates weak/no tools support, runtime warns and degrades by omitting tool declarations rather than failing deep in the loop.
- Model fallback chain:
OPENROUTER_MODEL+ optionalOPENROUTER_MODELS+ profile defaults. - OpenRouter
/modelsmetadata is cached at.openclaude/openrouter-models-cache.json. - Streaming mode is controlled via
OPENROUTER_STREAM=auto|on|off.
bun run doctor:runtime
bun run doctor:runtime:json
bun run doctor:reportThese validate OpenRouter config, compatibility aliases, reachability, and local-provider constraints.