Home / Docs / Migrating from the Anthropic API

Migrating from the Anthropic API

Move an existing Anthropic-SDK codebase over by changing two values.

Because the gateway speaks the Messages format, migration is a configuration change. Request bodies, response parsing, streaming handlers and tool definitions all stay as they are.

Python

from anthropic import Anthropic

client = Anthropic(
    api_key=class="s">"sk-your-gateway-key",   class=class="s">"c"># was your Anthropic key
    base_url=class="s">"https://aiprimetech.io",                   class=class="s">"c"># new line
)
class=class="s">"c"># everything below is unchanged

TypeScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.CLAUDEAPIKEY,
  baseURL: "https:">//aiprimetech.io",
});

Environment-only migration

export ANTHROPIC_BASE_URL="https://aiprimetech.io"
export ANTHROPIC_API_KEY="sk-your-gateway-key"

Migration checklist

  1. Change the base URL and the key. No /v1 suffix for Anthropic clients.
  2. Map model ids — see Models. Ids are pinned, so claude-3-5-sonnet-20241022 style names from an older integration need updating to a current id.
  3. Re-run your test suite. Response shapes are identical, so anything that breaks is a model-id or base-URL issue.
  4. Check streaming if you use it: the event shape is unchanged, but any hardcoded hostname in a proxy or allowlist needs updating.
  5. Move one service first and compare outputs before switching everything.

What does not carry over