Point Claude Code at OpenDunes and pay for its models in DA.
Claude Code is Anthropic's command-line coding agent. It speaks the Anthropic Messages API, which OpenDunes carries at /v1/messages — so Claude Code runs through OpenDunes with a few environment variables, and every call is billed to your wallet in DA.
curl -fsSL https://claude.ai/install.sh | bash
# or: npm install -g @anthropic-ai/claude-codeAdd these to your shell profile (~/.zshrc, ~/.bashrc):
export ANTHROPIC_BASE_URL="https://opendunes.com"
export ANTHROPIC_AUTH_TOKEN="$OPENDUNES_API_KEY"
export ANTHROPIC_API_KEY="" # must be empty
# Claude Code's own model names are not OpenDunes names: name each class
export ANTHROPIC_DEFAULT_OPUS_MODEL="~anthropic/claude-opus-latest"
export ANTHROPIC_DEFAULT_SONNET_MODEL="~anthropic/claude-sonnet-latest"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="~anthropic/claude-haiku-latest"
export CLAUDE_CODE_SUBAGENT_MODEL="~anthropic/claude-sonnet-latest"| Variable | Does |
|---|---|
ANTHROPIC_BASE_URL | Claude Code sends its requests to https://opendunes.com/v1/messages |
ANTHROPIC_AUTH_TOKEN | your OpenDunes API key, sent as Authorization: Bearer |
ANTHROPIC_API_KEY | left empty, so Claude Code does not send another credential |
ANTHROPIC_DEFAULT_*_MODEL · CLAUDE_CODE_SUBAGENT_MODEL | the model for each of Claude Code's classes, in OpenDunes names |
The model variables matter: Claude Code's built-in names, such as claude-sonnet-4-5, are not names OpenDunes sells, and answer 404. Any model from the catalogue goes — a ~…-latest name follows the newest of its family, an exact name such as anthropic/claude-sonnet-5 stays put.
Reload the profile (source ~/.zshrc) or open a new terminal, so the variables are live.
If Claude Code was signed in to an Anthropic account before, run /logout once inside it, then quit and relaunch claude. A cached login and a gateway key side by side conflict.
cd /path/to/your/project
claudeInside Claude Code, /status shows which credential is in use: it should name ANTHROPIC_AUTH_TOKEN. /model lists the models you set.
Every call Claude Code makes is billed in DA to the key's wallet, and shows in Activity by model and cost. Give Claude Code its own key with a spending cap — at Keys, or with POST /v1/keys and a limit — so a long agent session cannot drain the wallet.
| Symptom | Likely cause | Fix |
|---|---|---|
401 authentication_error | the key did not reach the session | re-export ANTHROPIC_AUTH_TOKEN, empty ANTHROPIC_API_KEY, relaunch |
404 not_found_error | a model name OpenDunes does not sell | set the four model variables to catalogue names |
402 billing_error | the wallet is empty, or the key's cap is spent | top up at Billing, or raise the key's cap |
~…-latest names move.