Migrate from the Anthropic API

Point the Anthropic SDK at ai.ml: /v1/messages accepts the Messages API including streaming, tools, thinking and prompt caching, and routes to Anthropic directly or to any other model.

Before

import anthropic
client = anthropic.Anthropic(api_key="sk-ant-…")
client.messages.create(model="claude-sonnet-4-5", max_tokens=1024, messages=msgs)

After

import anthropic
client = anthropic.Anthropic(base_url="https://api.ai.ml", api_key="aiml-live-…")
client.messages.create(model="anthropic/claude-sonnet-4.5", max_tokens=1024, messages=msgs)

Headers

Anthropicai.ml
x-api-key: sk-ant-…x-api-key: aiml-live-… (or Authorization: Bearer)
anthropic-versionkept; aiml-version (optional) pins the IR
anthropic-betaforwarded when the provider is Anthropic

What changes, what does not

  • x-api-key and anthropic-version headers are accepted as-is; the version pins the wire format, aiml-version pins ours.
  • Thinking blocks with signatures round-trip to Anthropic; other providers receive an equivalent reasoning budget where they support one.
  • Ask for a non-Anthropic model through the same endpoint (model: deepseek/deepseek-v3.2): tools and JSON schema are translated, unsupported features come back as warnings rather than silent drops.
  • 529 / overloaded from Anthropic is retried on another Anthropic host or failed over per your policy.