If you prefer Anthropic's native format, the anthropic package works with DEVSAIO by setting base_url to the site root.
import os, anthropic
client = anthropic.Anthropic(base_url="https://devsaio.lol", api_key=os.environ["DEVSAIO_API_KEY"])Streaming
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a limerick about Kubernetes."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Tool use
tools = [{
"name": "get_weather",
"description": "Get the current weather for a city",
"input_schema": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
}]
msg = client.messages.create(
model="claude-sonnet-4-6", max_tokens=1024, tools=tools,
messages=[{"role": "user", "content": "Do I need an umbrella in Lahore today?"}],
)
for block in msg.content:
if block.type == "tool_use":
print("Claude wants to call", block.name, "with", block.input)Your code runs the tool, then sends the result back as a tool_result block in the next user message, and Claude writes the final answer. The full loop is explained in function calling explained.
Counting tokens before sending
count = client.messages.count_tokens(model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Hello"}])
print(count.input_tokens)Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.