Quick start
Anthropic SDK
The Messages API served by the gateway; the Anthropic SDKs work unchanged.
The gateway implements the Anthropic Messages wire format at POST /v1/messages, including streaming, tool use, thinking blocks and prompt caching hints. Point the SDK at the gateway host (no /v1 suffix: the SDK adds it) and use an aiml key.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: process.env.AIML_BASE_URL ?? "https://api.ai.ml",
apiKey: process.env.AIML_API_KEY,
});
const message = await client.messages.create({
model: process.env.AIML_ANTHROPIC_MODEL ?? "anthropic/claude-sonnet-4.6",
max_tokens: 64,
messages: [{ role: "user", content: "Say hello in five words." }],
});
const text = message.content.filter((b) => b.type === "text").map((b) => b.text).join("");
console.log(text);
console.log(`stop_reason=${message.stop_reason} model=${message.model} request_id=${message.id}`);What to notice:
message.idis the aiml request id.max_tokensis required by the Messages format. If you omit it on a model whose catalog entry has a maximum, the gateway fills it in and adds aparam_clampedwarning tox-aiml-warnings.- Errors arrive in Anthropic's envelope (
{"type":"error","error":{"type","message"}}) with the stable aiml code inerror.code; see Errors.
Models
Anthropic models are anthropic/<model>, for example anthropic/claude-sonnet-4.6. Nothing stops you from calling an OpenAI model through the Messages route: the gateway translates between dialects. Capability gaps (a parameter the target cannot express) are reported as warnings, or as unsupported_feature.<name> errors when the loss would change the result.
Run it
AIML_API_KEY=aiml-live-… node --experimental-strip-types anthropic.ts
AIML_API_KEY=aiml-live-… python anthropic_messages.py