aiml docs
Migrate

From Anthropic

Keep the Anthropic SDK; change the base URL, the key and the model id.

The three changes

  1. Base URL https://api.anthropic.com becomes https://api.ai.ml (no /v1: the SDK appends it).
  2. Key sk-ant-… becomes aiml-live-….
  3. Model claude-sonnet-4.6 becomes anthropic/claude-sonnet-4.6. Bare Anthropic model names are accepted and resolve to anthropic/<name>.
cookbook/python/anthropic_messages.py#L5-L7
import anthropic

client = anthropic.Anthropic(base_url=os.environ.get("AIML_BASE_URL", "https://api.ai.ml"), api_key=os.environ["AIML_API_KEY"])

What stays the same

  • The Messages request: system, messages with content blocks, tools with input_schema, tool_choice, thinking, stop_sequences, metadata.user_id, cache_control on blocks.
  • Streaming events: message_start, content_block_start/delta/stop, message_delta, message_stop, ping.
  • The error envelope {"type":"error","error":{"type","message"}}; error.code adds the aiml code.

What is different

TopicAnthropicaiml
anthropic-version headerrequiredaccepted and ignored; use aiml-version
Request idrequest-id headerx-aiml-request-id header and the message id
Costnot returnedaiml.cost.total_micro_usd in the body, x-aiml-cost-micro header
529 overloaded_errorAnthropic capacity503 with code upstream_capacity; the gateway has usually already tried another endpoint
Billingpostpaidprepaid credits; 402 when the balance cannot cover the reserve

Thinking and signatures

Thinking blocks are replayed to Anthropic only when they carry the signature Anthropic issued; unsigned or foreign thinking blocks are dropped with a provider_block_dropped warning rather than rejected. When thinking is enabled, Anthropic forbids temperature, top_p and top_k; the gateway drops them with a warning instead of failing the call.

Calling non-Anthropic models

The Messages route is a dialect, not a vendor lock: model: "openai/gpt-5-mini" works. Parameters the target cannot express produce x-aiml-warnings; features that would change the result (for example a server tool the target lacks) return 422 unsupported_feature.<name>.

On this page