docs
SDKs and frameworks

Anthropic SDK (Python)

Markdown

SDK · Anthropic Messages

Full guide
FormatWhere to set it up
Anthropic MessagesThe Anthropic(base_url=...) parameter or ANTHROPIC_BASE_URL environment variable; key: api_key or ANTHROPIC_API_KEY

Setup

Copy the configuration and replace sk-... with your key from the Ailoot Dashboard. Prefer storing the key in the environment variable AILOOT_API_KEY, if the application supports it.

Before starting, request GET /v1/models with your Ailoot key. Choose an exact model ID whose methods include POST /v1/messages, then use that ID in the configuration. For agents, also check tool support and the features required by your client version.

export AILOOT_API_KEY="sk-..."
export ANTHROPIC_BASE_URL="https://api.ailoot.ai"
export ANTHROPIC_API_KEY="$AILOOT_API_KEY"

ailoot-anthropic-python-sdk.py

import os
from anthropic import Anthropic
client = Anthropic(max_retries=0, base_url="https://api.ailoot.ai", api_key=os.environ["AILOOT_API_KEY"])
msg = client.messages.create(
    model="claude-sonnet-5-5", max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}])
print(msg.content[0].text)
python3 ailoot-anthropic-python-sdk.py

Example model: claude-sonnet-5-5, claude-opus-5-5; also via /v1/messages gpt-6.1-sol, deepseek-v4-pro, gemini-3.6-flash. Choose any other model from the catalog — check that it supports the format you need.

Good to know

Test

  • For the Anthropic format, the URL is https://api.ailoot.ai without /v1.
  • Ask a short question. If you get an error, check the code and Request ID, then consult Errors and limits.
  • 404 immediately after setup almost always means the URL is wrong: an extra or missing /v1.
  • 402 — insufficient balance for the reserve. Agents reserve more than chat: why.

Application documentation: https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/python

Still have questions? Send your Request ID and a description — we'll help you troubleshoot.Contact support