Anthropic SDK
The Messages API with streaming, tools and thinking.
Your region's gateway address: resolving…
Setup
Set the SDK's base_url to the gateway address (the SDK appends /v1/messages) and use your Aitechestvo API key. cache_control blocks are preserved; the model alias decides the route to the provider.
Python
Streaming events arrive in the Anthropic format; placeholders are restored on the fly.
import os
import anthropic
client = anthropic.Anthropic(
base_url="https://<gateway>",
api_key=os.environ["AITECH_API_KEY"],
)
with client.messages.stream(
model="claude-sonnet",
max_tokens=1024,
messages=[{"role": "user", "content": "Prepare a memo for Ivanov Sergey"}],
) as stream:
for text in stream.text_stream:
print(text, end="")
TypeScript
If the model alias routes to a provider with a different format, the gateway translates the request and the response automatically.
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ baseURL: 'https://<gateway>', apiKey: process.env.AITECH_API_KEY });
const message = await client.messages.create({
model: 'claude-sonnet',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Check the payment to account 40702810900000012345' }],
});