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

[Connection](https://ailoot.ai/docs/en/) 

# Anthropic SDK

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

Messages format for Claude and other models: the official Anthropic SDKs and applications built on them.

## [](https://ailoot.ai/docs/connect/anthropic-sdk/#install)Installation

```bash
pip install anthropic
```

```bash
npm install @anthropic-ai/sdk
```

## [](https://ailoot.ai/docs/connect/anthropic-sdk/#client)Connection

The base URL is `https://api.ailoot.ai` **without** `/v1`: the SDK appends `/v1/messages`. Environment variables: `ANTHROPIC_BASE_URL` and `ANTHROPIC_API_KEY`.

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

```js
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);
```

## [](https://ailoot.ai/docs/connect/anthropic-sdk/#stream)Streaming responses

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

## [](https://ailoot.ai/docs/connect/anthropic-sdk/#thinking)Extended thinking

```python
msg = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    messages=[{"role": "user", "content": "Prove that there are infinitely many prime numbers"}],
)
```

## [](https://ailoot.ai/docs/connect/anthropic-sdk/#other-models)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.

```python
msg = client.messages.create(
    model="deepseek-v4-pro",
    max_tokens=2048,
    messages=[{"role": "user", "content": "Write a merge sort function in Go"}],
)
```

Message Batches, Files API, and token counting (`count_tokens`) are described separately: Message Batches and Files API are currently unavailable in Ailoot; token-count availability is checked separately for the selected model and key. Messages, streaming, tools, images and thinking use the original API’s format.

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.
