Skip to content
claude-code-router

claude-code-router via Tokonomix

Route Claude Code to Tokonomix with one provider block — send your hard turns to consensus and your boilerplate to a cheap model, by rule.

Provider block (config.json)Claude Code proxy / routerMIT · open sourceNode.js · all platforms
claude-code-router — route Claude Code to any backend, via Tokonomix

What is claude-code-router?

claude-code-router is a proxy that sits in front of Claude Code and routes each request to a backend of your choice by rule — cost, capability, context length. Point a Provider at Tokonomix and you can drive Claude Code with any of 130+ models, or with consensus, without changing how you use the CLI.

  • Intercepts Claude Code requests and forwards them to a configured backend.
  • Per-scenario Router rules: default, think, background, longContext.
  • Each backend is a Provider with a full chat-completions URL, key and model list.
  • Open source; configured from ~/.claude-code-router/config.json.

Why route through Tokonomix?

  • Send think turns to tokonomix-consensus and background turns to a cheap direct slug — automatically.
  • One Provider entry unlocks 130+ models for Claude Code.
  • Per-call spend caps and region / origin routing apply to every routed call.
  • Keep using Claude Code exactly as before — the routing is invisible.

Connect Tokonomix in config.json

Add a Tokonomix Provider with the full chat-completions URL (/chat/completions), your key and model list, then point Router rules at it (provider and model are comma-separated).

{
  "Providers": [
    {
      "name": "tokonomix",
      "api_base_url": "https://tokonomix.ai/api/v1/chat/completions",
      "api_key": "tok_live_your-key",
      "models": ["tokonomix-consensus", "anthropic/claude-sonnet-4-6"]
    }
  ],
  "Router": {
    "default": "tokonomix,anthropic/claude-sonnet-4-6",
    "think": "tokonomix,tokonomix-consensus",
    "background": "tokonomix,anthropic/claude-sonnet-4-6"
  }
}
Two details that bite

api_base_url is the full endpoint including /chat/completions (not just the base), and Router values are provider,model — a comma, not a slash.

Verify it works

  • Save config.json, start claude-code-router, and run Claude Code through it.
  • Trigger a reasoning-heavy task and confirm the think rule routed it to consensus.
  • Check the calls and token usage in your Tokonomix dashboard.

Model selection

Which model and endpoint should my agent use?

Pick by what your agent does, then swap the model id any time — every model in the catalog works through the same key.

What your agent doesUse this
Edits files / calls tools and streams responses (most coding agents)An Anthropic model via the Anthropic endpoint (tools + streaming both work)
Calls tools but does not need streaming (any model)The OpenAI-compatible endpoint with a single model id
Wants tools and streaming on a non-Anthropic modelRun non-streaming for now — streaming tool-calls on other providers is not enabled yet
Plain chat, no toolsEither endpoint; streaming is fine
Wants a cross-model verdict (consensus) on a high-stakes answerSet model to tokonomix-consensus on the OpenAI-compatible endpoint — note: consensus rejects tool requests (no tool-calling)
Endpoint & API reference (technical)

anthropic-messages → https://tokonomix.ai/api/anthropic — tools ✓, streaming ✓ (use an Anthropic model). openai-completions → https://tokonomix.ai/api/v1 — tools ✓ (single-model passthrough), streaming with tools not yet enabled. Plain chat: streaming works on both. Consensus: openai-completions, model tokonomix-consensus, no tools. Swap the model id to any slug returned by GET /api/v1/models.

Browse all models →

Related agents