Anthropic SDK
MarkdownMessages format for Claude and other models: the official Anthropic SDKs and applications built on them.
Full guide
Installation
pip install anthropicnpm install @anthropic-ai/sdkConnection
The base URL is https://api.ailoot.ai without /v1: the SDK appends /v1/messages. Environment variables: ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY.
import anthropic
import os
client = anthropic.Anthropic(max_retries=0,
base_url="https://api.ailoot.ai", # without /v1: the SDK adds /v1/messages itself
api_key=os.environ["AILOOT_API_KEY"],
)
msg = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain what an API is in two sentences."}],
)
print(msg.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ maxRetries: 0,
baseURL: "https://api.ailoot.ai", // without /v1
apiKey: process.env.AILOOT_API_KEY,
});
const msg = await client.messages.create({
model: "claude-sonnet-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain what an API is in two sentences." }],
});
console.log(msg.content[0].type === "text" ? msg.content[0].text : msg.content);Streaming responses
with client.messages.stream(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Tell a short story"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Streaming code works as it does with the original API, but billed text arrives in one block after the cost is calculated, rather than word by word. The SDK automatically skips the : ping control lines in long responses.
Extended thinking
msg = client.messages.create(
model="claude-opus-5-5",
max_tokens=16000,
messages=[{"role": "user", "content": "Prove that there are infinitely many prime numbers"}],
)Beyond Claude
Through /v1/messages you can also access GPT, DeepSeek, Qwen, Kimi, GLM, MiniMax, Grok, and Gemini: 776 identifiers in total. This is useful for clients that support only Anthropic format.
msg = client.messages.create(
model="deepseek-v4-pro",
max_tokens=2048,
messages=[{"role": "user", "content": "Write a merge sort function in Go"}],
)Still have questions? Send your Request ID and a description — we'll help you troubleshoot.Contact support