Skip to main content

Claude Code

Claude Code is Anthropic's official CLI agent, which also has a VS Code extension. By pointing it at a running Tresor instance, you can keep the Anthropic client experience while hot-switching the underlying model between Anthropic, DeepSeek, MiniMax, a local llama.cpp server, or any other configured downstream — all from the web UI.

No need to worry about the different API format underlying model is using, Tresor will auto-translate between the Anthropic API (Claude Code) to other API formats (e.g., gpt-5.5 using OpenAI Responses).

This page shows how to wire Claude Code CLI or VS Code extension to Tresor. For Claude Code inside Claude Desktop, follow Claude Desktop guide instead.

✅ Prerequisites​

1. Configure Tresor​

There are two ways to prepare Tresor:

Web UI is more intuitive, but require more manual operations.

  1. In "Downstreams" tab

    • Click + Add Provider to add the LLM provider you are about to use.
  2. In "Aliases" tab

    • Click + New Alias Group
      • Input Model ID: claude-opus.*
      • Checked "Regex Pattern"
      • Select the Downstream and Output Model IDs you added previously.
    • Repeat the above add new alias group process to add claude-sonnet.* and claude-haiku.*
  3. In "Settings" tab

    • Click + Add API Key under "Proxy Authentication" section (e.g, sk-proxy-123). Copy it, and we are about to fill it into ANTHROPIC_AUTH_TOKEN in the following section.

If a not-announced name like claude-opus-4-8 requests Tresor, the most precisely matched alias will still handle it (in this case, claude-opus.*). Optional announced names does not limit the capability of regex alias group's model name matching.

2. Configure Claude Code​

export ANTHROPIC_BASE_URL="http://127.0.0.1:11510"
export ANTHROPIC_AUTH_TOKEN="sk-proxy-123"
export ANTHROPIC_MODEL="claude-sonnet" # can be omitted, since we have used wildcard alias in Tresor
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus" # can be omitted, since we have used wildcard alias in Tresor
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet" # can be omitted, since we have used wildcard alias in Tresor
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku" # can be omitted, since we have used wildcard alias in Tresor
export CLAUDE_CODE_SUBAGENT_MODEL="claude-haiku" # can be omitted, since we have used wildcard alias in Tresor
Persist the variables

Drop the export lines into your shell profile (~/.bashrc, ~/.zshrc, or $PROFILE on PowerShell) so every new shell inherits them. Claude Code only reads the variables at launch — restart the CLI after editing your profile.

3. Launch Claude Code​

cd /path/to/my-project
claude

Claude Code will send the model name you set in ANTHROPIC_MODEL to Tresor, which will resolve it through the matching aliases entry and forward the request to the active downstream for that alias.

You can even switch the model in Claude Code to Opus, Sonnet, or Haiku via /model command: they will be matched by the regex wildcard alias claue-opus.*, claude-sonnet.*, and claue-haiku.*, and mapped to the model you specify in the Aliases tab.

4. Hot-switch from the web UI​

Open http://127.0.0.1:11510 in a browser, go to the Aliases tab, and click any sibling option card to make it active. Claude Code's next request will be routed to the new downstream — no restart of either Tresor or Claude Code is required. 🎉

For example, flip claude-sonnet from deepseek-flash to MiniMax-M2.7 with a single click, and the agent immediately starts using MiniMax on the following turn.

5. Using Web Search in Claude Code​

Tresor is fully API-compatible with the Anthropic Messages endpoint, so the Web Search tool works the same way it does with the official Anthropic API: when Claude Code's model decides a question needs fresh information, it invokes the Web Search tool and the search runs through the active downstream provider.

If the active downstream is DeepSeek, the search and the summarising LLM call both go through DeepSeek, so each search may incur extra token cost (one extra LLM call to summarise the retrieved pages).

If the active downstream is a local llama.cpp server, Web Search is not available unless that backend exposes the tool itself.

🔧 Troubleshooting​

SymptomLikely causeFix
401 Unauthorized from Tresorproxy_api_keys is set but ANTHROPIC_AUTH_TOKEN doesn't matchSet ANTHROPIC_AUTH_TOKEN to one of the keys in proxy_api_keys, or empty the list in config.yaml
404 model not found from TresorAlias exists but the chosen downstream isn't reachableOpen Logs, click the failing row, check the downstream error. Confirm base_url and that the local llama-server is up
Responses come back from the wrong modelAn alias is missing or matched a different regexIn the Aliases tab, verify the active card for the input model; regex aliases need is_regex: true

📚 See also​