Claude Code

Point Claude Code at Tchavi with two environment variables and run it on credits topped up by mobile money.

Part of the coding agents guides.

Claude Code speaks the Anthropic Messages API and nothing else. It cannot be pointed at an OpenAI-compatible endpoint. Tchavi therefore serves it a dedicated /v1/messages endpoint. Everything else (credits, rate limits, request logs) works exactly as it does for the rest of the API.

1. Set the variables

Bash
export ANTHROPIC_BASE_URL=https://tchavi.com/api
export ANTHROPIC_AUTH_TOKEN=sk-tch-your-key

Note the base URL stops at /api: Claude Code appends /v1/messages itself.

Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. Both work. Tchavi reads the key from either the Authorization or the x-api-key header, but ANTHROPIC_API_KEY needs a one-time approval inside Claude Code before it takes effect, and it is the more common source of a session that silently keeps using your old login.

If you were already signed in to claude.ai, run /logout once so the two credentials stop competing.

2. Check it before opening the agent

One request tells you whether the URL and the key are right, which is much easier to read than a failure inside the agent:

Bash
curl -sS -w '\n%{http_code}\n' -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-haiku-5-5","max_tokens":16,"messages":[{"role":"user","content":"Say OK"}]}'

A body starting with {"id":"msg_ and ending in 200 means you are done. A 401 means the key did not arrive. Check for a typo and that you exported it in the shell you are about to run claude in.

3. Choose your models

Claude Code's built-in model names are Anthropic's, and Tchavi carries those same names, so it works with no model configuration at all. But left alone, Claude Code starts on its default model, Claude Opus 5.5 with an API key according to its documentation, twice the price of Sonnet: choose your main model ("model" in step 4, or claude --model claude-sonnet-5-5) and pin the aliases to control what each one costs you:

Bash
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5

ANTHROPIC_DEFAULT_HAIKU_MODEL is worth setting deliberately: it also runs the background work (session titles, summaries) that you never see but do pay for.

You are not limited to Claude. Any tool-capable chat model in the catalogue works, because Tchavi translates between the two formats for you:

Bash
export ANTHROPIC_MODEL=gpt-6-sol        # or deepseek-v4.1-flash, kimi-k3, qwen3.8-max

Cheaper background work

Keep the Haiku alias on a budget model: claude-haiku-5-5 at 0.22 credits per 1K input, or glm-5.3-flash at 0.18. And background tasks cost almost nothing, without touching the quality of your actual coding turns.

4. Make it permanent

Shell exports last one terminal. To apply everywhere Claude Code runs, put them in the env block of ~/.claude/settings.json:

JSON
{
  "model": "claude-sonnet-5-5",
  "env": {
    "ANTHROPIC_BASE_URL": "https://tchavi.com/api",
    "ANTHROPIC_AUTH_TOKEN": "sk-tch-your-key",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}

Use ~/.claude/settings.json (yours, all projects) or .claude/settings.local.json (one project, git-ignored). Never a project's .claude/settings.json. That file is committed, and your key would go with it.

5. Show Tchavi models in the picker

Claude Code can read the catalogue from Tchavi and add it to /model:

Bash
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

It calls GET /v1/models at startup and keeps only entries whose id contains claude or anthropic. So the Claude models appear; gpt-6-sol and deepseek-v4.1-flash do not, and you select those with ANTHROPIC_MODEL instead.

What does not carry over

These are worth knowing before you decide, rather than discovering mid-task:

  • Prompt caching is not applied to Claude models. Claude Code marks parts of the conversation as cacheable; that marking is lost translating to and from the OpenAI shape, so a long session on a Claude model bills every turn as fresh input. On a big repository this is the difference that matters most. Point ANTHROPIC_MODEL at an OpenAI-backed model instead and caching does apply. The provider caches long prompts on its own, with no marker needed, and Tchavi bills those tokens at a tenth of the input rate (see Credits).
  • Remote Control and voice dictation stop working. Both require a claude.ai identity, which a gateway credential replaces.
  • /fast reports disabled. Its availability check needs a claude.ai login or an Anthropic API key; with only ANTHROPIC_AUTH_TOKEN, Claude Code treats fast mode as disabled without running the check.
  • /context is approximate. Tchavi answers the token-counting endpoint with a character-based estimate, not a real tokenizer. It is accurate enough to steer compaction; your bill uses the real counts the provider reports.

Next: OpenCode · Back to coding agents

On this page