CCRelay

Connect Claude Code and other agent clients to CoffeeRouter through CCRelay with an OpenAI Chat provider, local proxy configuration, and model mapping.

CCRelay is a local AI API relay that switches providers, converts protocols, and maps models between clients such as Claude Code, Claude Cowork, and Codex and their upstream model services. This guide adds CoffeeRouter as a CCRelay upstream provider and uses Claude Code for the final connection test.

Prerequisites

Before you begin, make sure that:

  • You have created an active token on the Token Management page in the CoffeeRouter console.
  • The token can access at least one chat model and has available quota.
  • Claude Code is installed if you want to follow the client test in this guide.
  • CCRelay is installed. Download the latest build from the official CCRelay Releases page.

CCRelay provides these installation options:

  • VS Code / Cursor extension: download the latest .vsix, open the editor command palette, run Extensions: Install from VSIX..., and select the downloaded file.
  • Desktop app: download the Windows or macOS installer that matches your operating system and processor architecture from the Releases page.

1. Open the CCRelay Dashboard

With the VS Code / Cursor extension, click the CCRelay status bar item, or open the command palette and run CCRelay: Open Dashboard. With the desktop app, choose Open Dashboard from the tray menu.

Open Providers, then click Add.

Open the CCRelay dashboard

2. Choose OpenAI Chat

In the Generic endpoints section of the provider wizard, choose OpenAI Chat. Do not choose OpenAI (full) or Anthropic for this guide; the configuration below uses the OpenAI Chat Completions compatible endpoint.

Choose OpenAI Chat when adding a provider

3. Enter the CoffeeRouter Configuration

Enter these values:

FieldValue
Display nameCoffeeRouter
API keyObtain it from CoffeeRouter Token Management, for example sk-your-api-key
Endpoint URLhttps://www.coffeerouter.ai/v1
Custom model listRecommended: choose Yes and enter model IDs available to the current token
Claude Cowork / Claude Code / Codex supportKeep enabled

After you enter the API key and endpoint, CCRelay attempts to load available models from https://www.coffeerouter.ai/v1/models. When the custom model list is enabled, use the returned model list as a reference and enter one model ID per line in the field on the right.

Each model ID must exactly match the value shown by CoffeeRouter, for example:

claude-sonnet-4-6
gpt-5.4

Never enter a real token in a public screenshot, documentation example, or support ticket.

Enter the CoffeeRouter provider credentials

4. Test and Create the Provider

Click Test at the bottom of the wizard. When the test passes, review the preview and click Create.

The wizard creates an enabled CoffeeRouter provider with these important settings:

SettingValuePurpose
Provider Typeopenai_chatUses the OpenAI Chat Completions upstream format
ModeinjectReplaces client authentication with the CoffeeRouter token
Auth HeaderauthorizationSends Authorization: Bearer ...
Base URLhttps://www.coffeerouter.ai/v1Joins with /chat/completions and /models

If Claude Cowork / Claude Code / Codex support is enabled, the wizard also generates mappings for Claude and GPT model names. You can open the provider editor after creation to review or adjust Model mapping (YAML).

Test the provider and configure model mappings

5. Select the CoffeeRouter Provider

Return to Providers and set CoffeeRouter as the current provider. You can also click the CCRelay status bar item or run CCRelay: Switch Provider, then choose CoffeeRouter.

Confirm that the local CCRelay server is running. It listens on 127.0.0.1 and port 7575 by default.

6. Configure Claude Code

Open Client configuration in the CCRelay dashboard, find the Claude Code section, and apply the settings shown there. CCRelay points Claude Code to its local Anthropic entry point:

http://127.0.0.1:7575/anthropic

To configure it manually, edit ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "ccrelay_apikey_placehold_do_not_need_to_setup_here",
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:7575/anthropic",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
  }
}

The ANTHROPIC_AUTH_TOKEN value above is only a placeholder sent to the local CCRelay process. It is not your CoffeeRouter API key. Store the real CoffeeRouter token only in the CCRelay provider.

Configure Claude Code to use CCRelay

7. Start and Test

  1. Confirm that CCRelay is running and CoffeeRouter is the current provider.
  2. Open a terminal and start Claude Code.
  3. Send a simple message and confirm that a response is returned.
  4. If the request fails, open Logs in CCRelay to review the status code, model mapping, and upstream error.

Manual Configuration Reference

If your CCRelay version does not include the provider wizard, or if you prefer to maintain the configuration file directly, edit ~/.ccrelay/config.yaml:

providers:
  coffeerouter:
    name: "CoffeeRouter"
    baseUrl: "https://www.coffeerouter.ai/v1"
    providerType: "openai_chat"
    mode: "inject"
    apiKey: "sk-your-api-key"
    authHeader: "authorization"
    modelMap:
      - pattern: "claude-opus-*"
        model: "your-coffeerouter-model-id"
      - pattern: "claude-sonnet-*"
        model: "your-coffeerouter-model-id"
      - pattern: "claude-haiku-*"
        model: "your-coffeerouter-model-id"
    enabled: true

defaultProvider: "coffeerouter"

Replace sk-your-api-key and your-coffeerouter-model-id with your own token and model ID. CCRelay also supports ${ENV_VAR} syntax in apiKey; when using an environment variable, make sure the process that launches CCRelay can read it.

Troubleshooting

Why must the Base URL include /v1?

An openai_chat provider directly joins its Base URL with /chat/completions and /models. With https://www.coffeerouter.ai/v1, requests reach the correct /v1/chat/completions and /v1/models endpoints.

Why do I get a 404 or a /v1/v1 URL?

Make sure the Base URL contains exactly one /v1. Do not enter https://www.coffeerouter.ai/v1/v1, and do not append /chat/completions to the Base URL.

Why do I get a 401 or 403 error?

Verify that the CoffeeRouter token is complete, enabled, and not expired. The provider should use inject mode and the authorization header. Also check quota, model permissions, and IP allowlist restrictions.

Why is Claude Code using the wrong model?

Review the provider's model mapping. Claude Code may send claude-opus-*, claude-sonnet-*, or claude-haiku-*; map these patterns to a real model ID available to the current CoffeeRouter token.

Why can't I open the dashboard directly in a browser?

This is a CCRelay access-protection mechanism. Use CCRelay: Open Dashboard or open the dashboard from the desktop app tray menu.

How do I revoke the CoffeeRouter token?

Disable or delete the token in CoffeeRouter Token Management, then update or remove the matching CCRelay provider. A dedicated token for CCRelay makes revocation easier.

Security Notes

  • ~/.ccrelay/config.yaml may contain the complete CoffeeRouter token. Do not upload, share, or commit it to Git.
  • Do not share screenshots, exported configurations, logs, or terminal output that contain a token. Examples in this guide use sk-your-api-key.
  • CCRelay binds only to 127.0.0.1 by default. Do not expose it to a LAN or the public internet unless you have configured access control, a firewall, and a trusted network.
  • Request logs may contain prompts, responses, and model information. Redact them before sharing.

Official Resources