SDKs

Anthropic SDK

The official Anthropic packages work against xKiro — and reach every model, not only Claude.

1

Install

pip install anthropic
2

Point the client at xKiro

import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["XKIRO_API_KEY"],
    base_url="https://api.xkiro.com",
)

No /v1 on this base URL

The Anthropic SDKs append /v1/messages themselves. Adding /v1 yourself produces /v1/v1/messages and a 404. This is the opposite of the OpenAI SDKs, and it is the single most common setup mistake.

3

Call a model

message = client.messages.create(
    model="anthropic/claude-opus-5",
    max_tokens=1024,
    system="You are a concise assistant.",
    messages=[{"role": "user", "content": "Hello"}],
)

print(message.content[0].text)

max_tokens is required in this dialect. Any model on xKiro can be named here — the Anthropic format is a request shape, not a vendor restriction.

4

Stream

with client.messages.stream(
    model="anthropic/claude-opus-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a haiku about caching."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Extended thinking#

Pass a thinking object. xKiro translates it for models that express reasoning differently, so the same code works across vendors.

const message = await client.messages.create({
  model: "anthropic/claude-opus-5",
  max_tokens: 4096,
  thinking: { type: "enabled", budget_tokens: 16000 },
  messages: [{ role: "user", content: "Prove sqrt(2) is irrational." }],
});

for (const block of message.content) {
  if (block.type === "thinking") console.log("[thinking]", block.thinking);
  if (block.type === "text") console.log(block.text);
}

Leaving thinking out is not the same as disabling it

Omit the field and each model applies its own default, which on some models is on. To turn it off, send { "type": "disabled" }. See Reasoning.

Tool calling#

const message = await client.messages.create({
  model: "anthropic/claude-opus-5",
  max_tokens: 1024,
  tools: [
    {
      name: "get_weather",
      description: "Get the current weather for a city.",
      input_schema: {
        type: "object",
        properties: { city: { type: "string" } },
        required: ["city"],
      },
    },
  ],
  messages: [{ role: "user", content: "Weather in Hanoi?" }],
});

const call = message.content.find((b) => b.type === "tool_use");

Return results as tool_result blocks inside a user message — see Tool calling.

What works#

  • messages.create and messages.stream.
  • messages.countTokens — see Count tokens.
  • models.list, via content negotiation on the same catalog endpoint.
  • Tool use, image blocks, thinking blocks and the SDK's error classes.

Claude Code and other Anthropic clients

Anything that accepts a custom base URL and API key works, including Claude Code. Set ANTHROPIC_BASE_URL to https://api.xkiro.com and ANTHROPIC_API_KEY to your xKiro key.

export ANTHROPIC_BASE_URL="https://api.xkiro.com"
export ANTHROPIC_API_KEY="sk-xt-..."