Connect Claude Code to DIAL
In this tutorial you point Claude Code, Anthropic's command-line coding agent, at DIAL and watch a DIAL-hosted model reply. Claude Code speaks the native Anthropic Messages API, and DIAL exposes that same API at /anthropic — so Claude Code talks to DIAL directly, with no proxy and no extra config file. You set a handful of environment variables, then run a prompt. This tutorial is for developers who already have a DIAL host and Claude Code installed.
Prerequisites
- A DIAL host and API key. See Before you begin.
- Claude Code installed —
npm i -g @anthropic-ai/claude-code.
What you'll build
A working connection from Claude Code to DIAL's Anthropic Messages API. By the end, claude -p sends a prompt and prints the reply, routed through your DIAL deployment with DIAL's roles, quotas, and cost tracking applied.
Step 1: Point Claude Code at DIAL
Set the following environment variables.
Bash or Zsh:
export ANTHROPIC_BASE_URL="https://<YOUR_DIAL_HOST>/anthropic"
export ANTHROPIC_API_KEY="<DIAL_API_KEY>" # keeps Claude Code out of its own login flow
export ANTHROPIC_CUSTOM_HEADERS="Api-Key: <DIAL_API_KEY>" # the header DIAL actually authenticates on
export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic.claude-opus-4-8"
export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic.claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic.claude-haiku-4-5-20251001-v1:0"
unset ANTHROPIC_AUTH_TOKEN # don't fall back to a personal token
export CLAUDE_CONFIG_DIR="/tmp/claude-ccr" # optional — see note below
PowerShell:
$env:ANTHROPIC_BASE_URL = "https://<YOUR_DIAL_HOST>/anthropic"
$env:ANTHROPIC_API_KEY = "<DIAL_API_KEY>"
$env:ANTHROPIC_CUSTOM_HEADERS = "Api-Key: <DIAL_API_KEY>"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "anthropic.claude-opus-4-8"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "anthropic.claude-sonnet-4-6"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "anthropic.claude-haiku-4-5-20251001-v1:0"
Remove-Item Env:\ANTHROPIC_AUTH_TOKEN -ErrorAction SilentlyContinue
$env:CLAUDE_CONFIG_DIR = "$env:TEMP\claude-ccr" # optional — see note below
These values point Claude Code at DIAL's /anthropic surface, authenticate with your DIAL key, and map Claude Code's three model tiers (Opus, Sonnet, Haiku) to DIAL deployment ids. Use the exact deployment id for each — Claude Code sends it to DIAL unchanged.
Warning
ANTHROPIC_CUSTOM_HEADERSis a full header line, not the bare key. Keep theApi-Key:header name and replace only<DIAL_API_KEY>, so the value readsApi-Key: your-real-key. If you paste the bare key without theApi-Key:prefix, DIAL sees no valid auth header and rejects the request with401 "At least API-KEY or Authorization header must be provided".ANTHROPIC_API_KEY, directly above it, is the bare key.
Note
CLAUDE_CONFIG_DIRis optional and only for trying this out. It points Claude Code at a throwaway config directory, so this experiment does not disturb the login of a Claude Code you may already use. For a permanent DIAL setup, leave it unset.
Step 2: Run Claude Code
claude -p "Reply with exactly: PONG"
Verify:
You see PONG printed back, answered by your DIAL deployment with no proxy in between. Run plain claude for the interactive session you will use day to day.
Make it permanent with settings.json
Instead of re-exporting every shell, put the same values in Claude Code's settings file — ~/.claude/settings.json (or $CLAUDE_CONFIG_DIR/settings.json; on Windows, %USERPROFILE%\.claude\settings.json). The JSON is identical on every platform; only the path differs:
{
"env": {
"ANTHROPIC_BASE_URL": "https://<YOUR_DIAL_HOST>/anthropic",
"ANTHROPIC_API_KEY": "<DIAL_API_KEY>",
"ANTHROPIC_CUSTOM_HEADERS": "Api-Key: <DIAL_API_KEY>",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic.claude-opus-4-8",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic.claude-sonnet-4-6",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic.claude-haiku-4-5-20251001-v1:0"
}
}
For this permanent form you typically do not set CLAUDE_CONFIG_DIR — that was only to isolate the trial above.
What you learned
- How to point Claude Code at DIAL's
/anthropicsurface with environment variables. - Why two key settings are needed — one for auth, one to skip the sign-in flow.
- How to make the connection permanent through Claude Code's
settings.json.
Good to know
- No proxy needed. DIAL's
/anthropicsurface speaks the native Anthropic Messages API, so Claude Code reaches it directly, unlike Codex. To check that a host exposes it,POSTtohttps://<YOUR_DIAL_HOST>/anthropic/v1/messages— a configured host returns200, one without the surface returns404. - Why two key settings: DIAL does not accept the
x-api-keyheader that Claude Code normally sends fromANTHROPIC_API_KEY; it authenticates on theApi-Keyheader (or anAuthorization: Bearertoken). That is why you setANTHROPIC_CUSTOM_HEADERS="Api-Key: …".ANTHROPIC_API_KEYstays set only so Claude Code treats itself as logged in and skips its own sign-in flow. - Use exact deployment ids, and set all three tiers. Claude Code routes small background tasks to the Haiku tier, so a missing or wrong
ANTHROPIC_DEFAULT_HAIKU_MODELfails those turns. Haiku's full id isanthropic.claude-haiku-4-5-20251001-v1:0— a shortened form is rejected as an unknown deployment. - Tool calling and vision work only when the chosen DIAL deployment advertises those capabilities.
- This tutorial was verified against DIAL v0.46. Other DIAL releases may not expose
/anthropic; use the 200/404 check above to confirm yours does.
Next steps
- Connect Codex to DIAL — a command-line agent that may need a translating proxy
- Agentic tools overview — shared prerequisites and the other tools
- Unified API reference — the API DIAL exposes