Skip to content

CCR - Claude Code Router Guide

CCR here refers to the specific project Claude Code Router, not a generic class of Claude routing tools.

Claude Code Router is maintained by musistudio. Its role is to:

  • use Claude Code as the base developer workflow
  • route Claude Code requests to different providers and models
  • transform requests and responses when provider compatibility differs
  • support dynamic model switching through /model
  • support terminal and UI-based management with ccr model, ccr ui, and presets
  • support ccr activate so your current shell can use the router transparently

Official links:

Read this first

Claude Code Router is a routing and compatibility layer for Claude Code. When you connect it to Dli.li AI, you are configuring CCR `Providers` and `Router` rules. You are not directly wiring every model to Anthropic-native `/messages`.

How CCR works with Dli.li AI

The usual integration flow is:

  1. Add a Dli.li AI provider in CCR Providers
  2. List the models available to your account in that provider
  3. Use Router to assign models for default, background, think, longContext, and similar routes
  4. Start CCR and launch Claude Code through ccr code or eval "$(ccr activate)"

That means:

  • Claude Code talks to the local CCR service first
  • CCR forwards the request to the provider endpoint you configured
  • CCR can optionally apply transformers when provider compatibility needs adjustment

Official endpoints

For CCR, api_base_url should be the full chat completions endpoint, not only the /v1 root.

TypeURLTypical usage
Official default APIhttps://api.dli.li/v1/chat/completionsOfficial default call URL
Official backup APIhttps://api.dlizz.com/v1/chat/completionsOfficial backup call URL

API recommendation

You can set `api_base_url` to the official default API `https://api.dli.li/v1/chat/completions`; if you want the official backup API directly, use `https://api.dlizz.com/v1/chat/completions`.

Installation and startup

Make sure Claude Code is installed first:

bash
npm install -g @anthropic-ai/claude-code

Then install Claude Code Router:

bash
npm install -g @musistudio/claude-code-router

Typical workflow:

bash
# start the local router service
ccr start

# launch Claude Code through CCR
ccr code

If you want to keep using the claude command directly:

bash
eval "$(ccr activate)"
claude

What activate does

`ccr activate` exports environment variables such as `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` so the current shell points to the local CCR service. You still need `ccr start` first.

The main config file is typically:

text
~/.claude-code-router/config.json

For Dli.li AI, the two key sections are:

  • Providers: defines upstream model providers
  • Router: defines which model is used in each route category

A minimal example for Dli.li AI:

json
{
  "Providers": [
    {
      "name": "dlili",
      "api_base_url": "https://api.dli.li/v1/chat/completions",
      "api_key": "$DLILI_API_KEY",
      "models": [
        "claude-3-7-sonnet",
        "claude-3-5-sonnet",
        "gpt-4o-mini"
      ]
    }
  ],
  "Router": {
    "default": "dlili,claude-3-7-sonnet",
    "background": "dlili,gpt-4o-mini",
    "think": "dlili,claude-3-7-sonnet",
    "longContext": "dlili,claude-3-5-sonnet"
  }
}

Notes:

  • name is your own provider identifier
  • api_base_url should include the full /v1/chat/completions path
  • api_key is best injected from an environment variable
  • the models list must match the exact names exposed by Dli.li AI
  • router values commonly use the format provider_name,model_name

About transformers

Claude Code Router supports transformers to adapt request and response payloads for providers that differ from the default shape.

For Dli.li AI, which exposes an OpenAI-compatible endpoint, the safest first step is usually to start without a transformer.

Add transformers later only if:

  • you are also routing to non-OpenAI-compatible providers
  • a target model needs provider-specific request shaping
  • you want extra CCR features such as tooluse, reasoning, or maxtoken

Model selection checklist

  1. Check Profile for the models available to your account.
  2. Check API Tokens to make sure the current key does not exclude that model.
  3. Put the exact model name into the CCR models list.
  4. Reference it from Router using the provider,model format.

FAQ

Why does it still fail after configuration

Check these items first:

  • api_base_url includes the full /v1/chat/completions path
  • the API key belongs to the current account
  • the model names exactly match the site-exposed model names
  • you restarted CCR after changing config.json, for example with ccr restart or a fresh ccr start

Why is the claude command not using CCR

Usually because:

  • you did not run eval "$(ccr activate)"
  • or the local CCR service is not running yet

Start with:

bash
ccr start
eval "$(ccr activate)"

Why can I not use the backup domain for login or payment

Because external account linking and on-site payments must use the main site https://dli.li. Backup and acceleration domains are for API traffic, not account-system operations.

How should I assign routes first

A practical starting order is:

  1. default: your main everyday model
  2. background: a cheaper or faster model
  3. think: a stronger reasoning model
  4. longContext: a model better suited for longer context windows

Get the basic route working first, then refine.