DEVSAIO

Using the Anthropic Messages API format on DEVSAIO

Claude Code and the Anthropic SDKs speak the Messages API. Here is how to point them at DEVSAIO, with Python and TypeScript examples.

DEVSAIO team · 2 min read
Share on X

Anthropic's own API uses a format called the Messages API (POST /v1/messages). It's slightly different from OpenAI's: the system prompt is a top-level field, max_tokens is required, and the answer comes back as a list of content blocks. DEVSAIO accepts this format natively, so Anthropic tools work unchanged.

The base URL

For Anthropic-style clients, use the site root (the SDK adds /v1/messages itself):

text
https://devsaio.lol

Python

bash
pip install anthropic
python
import anthropic

client = anthropic.Anthropic(base_url="https://devsaio.lol", api_key="YOUR_KEY")

msg = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    system="You are a concise assistant.",
    messages=[{"role": "user", "content": "What is a race condition?"}],
)
print(msg.content[0].text)

TypeScript

bash
npm install @anthropic-ai/sdk
ts
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "https://devsaio.lol", apiKey: process.env.DEVSAIO_API_KEY });
const msg = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Write a regex for UK postcodes." }],
});
console.log(msg.content[0].type === "text" ? msg.content[0].text : msg.content);

curl

bash
curl https://devsaio.lol/v1/messages \
  -H "x-api-key: $DEVSAIO_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model": "claude-sonnet-4-6", "max_tokens": 512, "messages": [{"role": "user", "content": "Hi!"}]}'

Which format should I use?

  • Use Messages when a tool or SDK is built for Claude, or when you rely on Claude-specific response details.
  • Use Chat Completions when you want one code path for every lab.

Both are billed the same way from your one balance. Next: set up Claude Code with a custom base URL.

Try it with one API key

Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.

Keep reading