> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Claude Code with the gateway

> Point Claude Code at LLM Gateway 2.0 from every Workspace in a Compute Environment, a single Workspace, or outside Domino, and serve it from any alias.

Claude Code talks to the LLM Gateway 2.0 `/anthropic/v1/messages` endpoint, and any alias can serve it, including GPT, Gemini, and Domino-hosted models. Grants, budgets, and guardrails apply as they do to other traffic. The usage dashboard can group each session by its `claude-code-session` tag.

## How requests reach the model

Anthropic aliases, and Claude on Bedrock or Vertex, receive requests unchanged, so prompt caching markers, extended thinking, and beta headers work.

Every other alias gets the request translated to OpenAI Chat Completions. Tool use, vision, and multi-turn conversations work. Prompt caching markers, extended thinking, and Anthropic beta headers are dropped.

## Set up every Workspace in a Compute Environment

If you own the Compute Environment, add this to its **Pre Run Script**. Every Workspace built from it starts with Claude Code pointed at the gateway, and the gateway tags requests with the Project name.

```bash theme={null}
cat > "$HOME/.anthropic-headers.sh" <<'EOF'
if [ -n "$DOMINO_PROJECT_NAME" ]; then
  export ANTHROPIC_CUSTOM_HEADERS="X-LLM-Tag-projectname: $DOMINO_PROJECT_NAME"
fi
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
export ANTHROPIC_BASE_URL="https://<your-domino-host>/apps/<gateway-app-id>/anthropic"
EOF

CODE_DIR="${DOMINO_WORKING_DIR:-/mnt}"
mkdir -p "$CODE_DIR/.claude"
cat > "$CODE_DIR/.claude/settings.local.json" <<'EOF'
{
  "apiKeyHelper": "curl -sf http://localhost:8899/access-token"
}
EOF

MARKER="# >>> domino anthropic headers >>>"
if ! grep -qF "$MARKER" "$HOME/.bashrc" 2>/dev/null; then
  cat >> "$HOME/.bashrc" <<EOF

$MARKER
[ -f "\$HOME/.anthropic-headers.sh" ] && . "\$HOME/.anthropic-headers.sh"
# <<< domino anthropic headers <<<
EOF
fi
```

Start a Workspace, `cd` into the Project directory, and run `claude --model <alias-name>`. Launch from inside the Project directory, or Claude Code won't find `settings.local.json`.

The script rewrites `.claude/settings.local.json` on every Workspace start. Add it to `.gitignore` in Git-based Projects, and put personal Claude Code settings in `.claude/settings.json` instead.

## Set up a single Workspace

Without access to the Compute Environment, write the same settings to your user config:

```bash theme={null}
mkdir -p "$HOME/.claude"
cat > "$HOME/.claude/settings.json" <<EOF
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://<your-domino-host>/apps/<gateway-app-id>/anthropic",
    "ANTHROPIC_CUSTOM_HEADERS": "X-LLM-Tag-projectname: ${DOMINO_PROJECT_NAME}",
    "CLAUDE_CODE_ATTRIBUTION_HEADER": "0"
  },
  "apiKeyHelper": "curl -sf http://localhost:8899/access-token"
}
EOF
```

## Use the gateway from outside Domino

From a laptop or a continuous integration (CI) system, the sidecar isn't available. Use a Domino API key:

```bash theme={null}
export ANTHROPIC_BASE_URL=https://<your-domino-host>/apps/<gateway-app-id>/anthropic
export ANTHROPIC_AUTH_TOKEN=<your-domino-api-key>
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model <alias-name>
```

## Before you roll it out

* **Register a Haiku alias.** Claude Code makes background calls for titles and summaries to its default Haiku model by its Anthropic name. Without an alias of that exact name, those calls return `404` and titles and summaries degrade.
* **Keep `CLAUDE_CODE_ATTRIBUTION_HEADER=0`.** Without it, the system prompt changes on every turn and prompt caching never hits.
* **Size alias ceilings for many small requests.** An alias ceiling that runs out stops Claude Code mid-session. To limit extended-thinking spend, set `LLM_GATEWAY_MAX_THINKING_BUDGET_TOKENS`.
* **Tune timeouts and retries.** Each alias retries on its own, and Claude Code retries up to 10 more times on top. For slow self-hosted models, raise the alias's per-attempt timeout (default 60 seconds). To fail faster, lower its **Max Retries**.
* **Keep request bodies small.** The Domino App proxy rejects request bodies larger than about 25 MB with a `413`.
* **Pass tags explicitly from the Anthropic Python software development kit (SDK).** The SDK doesn't read `ANTHROPIC_CUSTOM_HEADERS`. Pass tags with `default_headers` on the client.

## Related

* [Control access, spend, and usage](/cloud/admin/platform-configuration/llm-gateway/access-and-spend): set alias ceilings and grant budgets for Claude Code traffic, and break down spend by session or Project tag.


## Related topics

- [LLM Gateway 2.0](/cloud/platform-capabilities/features/llms/llm-gateway/index.md)
- [Auto Model Documentation](/cloud/platform-capabilities/features/extensions/auto-model-documentation.md)
- [Call decision models](/cloud/platform-capabilities/features/llms/llm-gateway/decision-models.md)
- [Get started with AI coding assistants](/cloud/platform-capabilities/features/coding-assistants/get-started.md)
