Skip to main content

Migrating

If you already call Claude, migration is a base URL and a key. The work is in checking the things that are genuinely different.

From the Anthropic API

Before:

client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

After:

client = Anthropic(
    api_key=os.environ["GATEWAY_API_KEY"],
    base_url="{BASE_URL_ROOT}",
)

Request and response shapes are identical, errors use the same envelope, and streaming uses the same events. Your existing retry and error handling continues to work.

Pre-flight checklist

  • Check your models are on your tier. The UK tier serves claude-sonnet-4-6 and claude-opus-4-6 only. If your code asks for Opus 5 on a UK account it will get residency_unavailable, by design. See the catalogue.
  • Decide your privacy mode. Start on flag in staging and look at what gets detected before switching to tokenise. It is a cheap way to find out that your prompts contain more personal data than you thought.
  • Raise your client timeout to 180 seconds if it is lower.
  • Check your rate limits. Concurrency in particular is per plan, and a batch job sized for Anthropic's limits may need adjusting.
  • Remove any dependency on unproxied features — Files API, server-side tools, batches. Full list.

Verifying residency

Do not take our word for it. Every response says where it was processed, so you can assert on it in your own integration tests and keep the evidence in your own logs.

# Confirm where a request was actually processed.
curl -sS -D - -o /dev/null https://ai.dijitul.uk/v1/messages \
  -H "x-api-key: $GATEWAY_API_KEY" \
  -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-4-6","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}' \
  | grep -i '^x-gateway'

# x-gateway-residency: uk
# x-gateway-regions: eu-west-2

If x-gateway-regions ever returns something other than what your tier permits, that is a bug and we want to hear about it immediately.

Model names

Short aliases are canonical, but dated identifiers are accepted and normalised, so code copied from Anthropic's documentation works without editing.

Rolling back

Migration is a configuration change, so rollback is too — restore the original base URL and key. We deliberately hold nothing that would make leaving difficult: no prompt history to export, no proprietary request format to unpick.

Migrating an OpenAI-based integration is not yet a one-line change — an OpenAI-compatible /v1/chat/completions endpoint is on the roadmap but is not live. For now, use an Anthropic client.