Anthropic SDK (Python)
MarkdownSDK · Anthropic Messages
Full guide
| Format | Where to set it up |
|---|---|
| Anthropic Messages | The 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.pyExample 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.aiwithout/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