Messages (Anthropic-compatible)
Use the Anthropic Messages API format with Zen models via api.hanzo.ai
Messages API (Anthropic-compatible)
Zen models are reachable through the Anthropic Messages wire format at the
same base URL, alongside the chat-completions format. This is a second envelope
we speak so that a client already written against that shape can call Zen models
without being rewritten — point its base URL at https://api.hanzo.ai/v1 and
give it a Hanzo key. Model ids do not carry across vendors: the ids below are
Hanzo models and resolve only here.
Endpoint
POST https://api.hanzo.ai/v1/messagesAuthentication
x-api-key: $HANZO_API_KEY
# or
Authorization: Bearer $HANZO_API_KEYInclude the anthropic-version header:
anthropic-version: 2023-06-01Quickstart
curl
curl https://api.hanzo.ai/v1/messages \
-H "x-api-key: $HANZO_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "zen5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, Zen."}]
}'Python (Anthropic SDK)
from anthropic import Anthropic
client = Anthropic(
api_key="hk-your-api-key",
base_url="https://api.hanzo.ai/v1",
)
message = client.messages.create(
model="zen5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Zen."}],
)
print(message.content[0].text)TypeScript (Anthropic SDK)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "hk-your-api-key",
baseURL: "https://api.hanzo.ai/v1",
});
const message = await client.messages.create({
model: "zen5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Zen." }],
});
console.log(message.content[0].text);Streaming
curl https://api.hanzo.ai/v1/messages \
-H "x-api-key: $HANZO_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "zen5",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Hello, Zen."}]
}'Streaming uses Server-Sent Events (SSE), identical to the Anthropic streaming format.
Supported Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Zen model ID (e.g., zen5, zen5-pro, zen5-coder) |
messages | array | Yes | Array of message objects with role and content |
max_tokens | integer | Yes | Maximum tokens to generate |
stream | boolean | No | Enable SSE streaming (default: false) |
temperature | float | No | Sampling temperature (0.0 - 1.0) |
top_p | float | No | Nucleus sampling parameter |
system | string | No | System prompt |
stop_sequences | array | No | Stop generation at these sequences |
Response Format
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"model": "zen5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 12,
"output_tokens": 15
}
}Using Both Formats
The same api.hanzo.ai/v1 host serves both wire formats:
| Wire format | Endpoint | Clients |
|---|---|---|
| Chat completions | POST /v1/chat/completions | hanzoai, @hanzo/ai, or any client written for that shape |
| Messages | POST /v1/messages | anthropic |
| Catalogue | GET /v1/models | Any HTTP client |
All Zen models work with both. Use whichever your application already speaks.