Skip to main content

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​

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>" # sent as x-api-key, which DIAL 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 # an Authorization header would take precedence in DIAL
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_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

The first time you start an interactive claude session with ANTHROPIC_API_KEY set, Claude Code asks once whether to use the key. The prompt can show it with an sk-ant- prefix; it is still your DIAL key. Approve it. If you decline, Claude Code ignores the key without asking again, and requests to DIAL fail with 401. To turn it back on, run /config and enable Use custom API key.

note

CLAUDE_CONFIG_DIR is 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. In that session, /status shows an Anthropic base URL line with your DIAL host and an API key line naming ANTHROPIC_API_KEY.

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_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.

Good to know​

  • No proxy needed. DIAL's /anthropic surface speaks the native Anthropic Messages API, so Claude Code reaches it directly, unlike Codex. To check that a host exposes it, POST to https://<YOUR_DIAL_HOST>/anthropic/v1/messages — a configured host returns 200, one without the surface returns 404.
  • Keep ANTHROPIC_AUTH_TOKEN unset. Claude Code sends ANTHROPIC_API_KEY in the x-api-key header, which DIAL reads when a request has no Api-Key or Authorization header. ANTHROPIC_AUTH_TOKEN adds an Authorization header, and DIAL then authenticates on that instead.
  • 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_MODEL fails those turns. Haiku's full id is anthropic.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.
  • DIAL Core adds the /anthropic endpoint in 0.46.0. Earlier releases don't have it; use the 200/404 check above to confirm yours does.

Further reading​