Skip to main content

Claude Code

Claude Code is Anthropic's terminal coding agent. It reads its endpoint and credential from environment variables, so pointing it at the Cequence AI Gateway is a matter of exporting the right values before you start it — no config file to edit.

Setup

Claude Code speaks Anthropic's native API shape. Pick the mode your LLM Registry entry runs in.

The gateway stores the Anthropic credential on the entry, so Claude Code sends only its Agent Access Key.

export ANTHROPIC_BASE_URL="https://<gateway-host>/llm/<url-prefix>"
export ANTHROPIC_API_KEY="<your-agent-access-key>"
export ANTHROPIC_MODEL="<model-id>"

Then restart Claude Code, or open a new terminal, so it picks up the new environment.

What each line does:

  • ANTHROPIC_BASE_URL points Claude Code at the gateway instead of Anthropic's API directly.
  • ANTHROPIC_API_KEY carries your Agent Access Key. Claude Code sends this value as the x-api-key header, which the gateway accepts as the caller's credential. The gateway then attaches the stored Anthropic credential on the outbound side.
  • ANTHROPIC_MODEL sets which model Claude Code requests. Use an identifier from the entry's Allowed Models list. Leave it out to keep Claude Code's own default — but if the entry restricts models, its default may not be one the entry permits.

Where to find each value

PlaceholderWhere to find it
<gateway-host>Host from the LLM Registry entry's Overview tab (e.g., gw.aigateway.example.com)
<url-prefix>The URL prefix field on the entry's Overview tab
<model-id>A model identifier from the entry's Allowed Models list
<your-agent-access-key>Generate from the LLM Registry entry's Agent Access Keys step; plaintext is shown once
<your-anthropic-api-key>Your own Anthropic API key — only needed in passthrough mode

The entry's Connect flow assembles all of this for you with the real values filled in, ready to copy.

Tips

  • ANTHROPIC_API_KEY must always be set. If Claude Code finds it empty, it falls back to its own sign-in flow and never reaches the gateway — which looks like the gateway ignoring you, when in fact Claude Code never sent it a request.
  • Restart after any change. Claude Code reads these variables at startup only, so export them and then start a fresh session.
  • Check the endpoint before the credential. If Claude Code reports a generic authentication error, compare ANTHROPIC_BASE_URL against the URL shown in the entry's Connect flow first — a wrong URL prefix produces the same error message as a bad key.
  • Unset when finished. If you set these only to try the gateway out, run unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY ANTHROPIC_CUSTOM_HEADERS ANTHROPIC_MODEL to return Claude Code to its normal behavior — otherwise every later session keeps routing through the gateway.