Skip to main content

Connect Claude Code to DIAL

Introduction

From this tutorial, you will learn how to 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. 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.

Prerequisites

  • A DIAL host and API key. Refer to Prerequisites.
  • Claude Code installed — npm i -g @anthropic-ai/claude-code.

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_HEADERS is a full header line, not the bare key. Keep the Api-Key: header name and replace only <DIAL_API_KEY>, so the value reads Api-Key: your-real-key. If you paste the bare key without the Api-Key: prefix, DIAL sees no valid auth header and rejects the request with 401 "At least API-KEY or Authorization header must be provided". ANTHROPIC_API_KEY, directly above it, is the bare 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"

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.

Additional Information

No proxy is 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.

  • Why two key settings: DIAL does not accept the x-api-key header that Claude Code normally sends from ANTHROPIC_API_KEY; it authenticates on the Api-Key header (or an Authorization: Bearer token). That is why you set ANTHROPIC_CUSTOM_HEADERS="Api-Key: …". ANTHROPIC_API_KEY stays 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_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.
  • 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.