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 activateso your current shell can use the router transparently
Official links:
- Chinese docs: https://musistudio.github.io/claude-code-router/zh-CN/
- English docs: https://musistudio.github.io/claude-code-router/
- GitHub: https://github.com/musistudio/claude-code-router
Read this first
How CCR works with Dli.li AI
The usual integration flow is:
- Add a Dli.li AI provider in CCR
Providers - List the models available to your account in that provider
- Use
Routerto assign models fordefault,background,think,longContext, and similar routes - Start CCR and launch Claude Code through
ccr codeoreval "$(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.
| Type | URL | Typical usage |
|---|---|---|
| Official default API | https://api.dli.li/v1/chat/completions | Official default call URL |
| Official backup API | https://api.dlizz.com/v1/chat/completions | Official backup call URL |
API recommendation
Installation and startup
Make sure Claude Code is installed first:
npm install -g @anthropic-ai/claude-codeThen install Claude Code Router:
npm install -g @musistudio/claude-code-routerTypical workflow:
# start the local router service
ccr start
# launch Claude Code through CCR
ccr codeIf you want to keep using the claude command directly:
eval "$(ccr activate)"
claudeWhat activate does
Recommended configuration model
The main config file is typically:
~/.claude-code-router/config.jsonFor Dli.li AI, the two key sections are:
Providers: defines upstream model providersRouter: defines which model is used in each route category
A minimal example for Dli.li AI:
{
"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:
nameis your own provider identifierapi_base_urlshould include the full/v1/chat/completionspathapi_keyis best injected from an environment variable- the
modelslist 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, ormaxtoken
Model selection checklist
- Check Profile for the models available to your account.
- Check API Tokens to make sure the current key does not exclude that model.
- Put the exact model name into the CCR
modelslist. - Reference it from
Routerusing theprovider,modelformat.
FAQ
Why does it still fail after configuration
Check these items first:
api_base_urlincludes the full/v1/chat/completionspath- 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 withccr restartor a freshccr 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:
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:
default: your main everyday modelbackground: a cheaper or faster modelthink: a stronger reasoning modellongContext: a model better suited for longer context windows
Get the basic route working first, then refine.
