Source: https://ailoot.ai/docs/en/integrations/anthropic-python-sdk/
Canonical: https://ailoot.ai/docs/en/integrations/anthropic-python-sdk/
Language: en

[SDKs and frameworks](https://ailoot.ai/docs/en/integrations/#sdk) 

# Anthropic SDK (Python)

[Markdown](https://ailoot.ai/docs/en/integrations/anthropic-python-sdk/index.md)

SDK · Anthropic Messages

| 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 |

## [](https://ailoot.ai/docs/en/integrations/anthropic-python-sdk/#setup)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.

```bash
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`

```python
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)
```

```bash
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](https://ailoot.ai/models/en/) — check that it supports the format you need.

## [](https://ailoot.ai/docs/en/integrations/anthropic-python-sdk/#notes)Good to know

Use a URL WITHOUT /v1: the SDK adds /v1/messages itself. The gateway accepts the key in x-api-key (as sent by the SDK) and Authorization: Bearer. Streaming, tools, and /v1/messages/count\_tokens work. Batch processing (Batches) and the Files API are not listed as supported in the Ailoot catalog.

## [](https://ailoot.ai/docs/en/integrations/anthropic-python-sdk/#check)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](https://ailoot.ai/docs/en/errors/).
- 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](https://ailoot.ai/docs/en/billing/reserve/).

Application documentation: [https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/python](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](mailto:support@ailoot.ai)

## Ailoot · The company and its project portfolio





Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.





The company and its project portfolio: millions of customers; monthly sales in the billions.





Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
