Create messages — POST /v1/messages
Implements the Anthropic Messages API.
POST /v1/messages
| Address | https://api.hanzo.ai/v1/messages |
| Method | POST |
| Operation | post_messages |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Implements the Anthropic Messages API.
Request
14 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
max_tokens | body | integer | — | |
messages | body | ai.AnthropicMessage[] | — | |
messages[].content | body | any | — | |
messages[].role | body | string | — | |
model | body | string | — | |
stream | body | boolean | — | |
system | body | any | — | |
temperature | body | number | — | |
thinking | body | any | — | |
tool_choice | body | any | — | |
tools | body | ai.AnthropicTool[] | — | |
tools[].description | body | string | — | |
tools[].input_schema | body | any | — | |
tools[].name | body | string | — |
Response
| Status | Body | Meaning |
|---|---|---|
200 | ai.AnthropicResponse | Success. |
401 | — | No credential, or one this service does not accept. |
403 | — | A valid credential that may not do this. |
200 body — 17 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
content | body | ai.AnthropicContentBlock[] | — | |
content[].text | body | string | — | |
content[].type | body | string | — | |
id | body | string | — | |
model | body | string | — | |
role | body | string | — | |
stop_reason | body | string | — | |
type | body | string | — | |
usage | body | ai.AnthropicUsage | — | |
usage.cache_creation | body | ai.CacheWrites | — | |
usage.cache_creation.ephemeral_1h_input_tokens | body | integer | — | |
usage.cache_creation.ephemeral_5m_input_tokens | body | integer | — | |
usage.cache_creation_input_tokens | body | integer | — | |
usage.cache_read_input_tokens | body | integer | — | |
usage.input_tokens | body | integer | — | |
usage.iterations | body | ai.AnthropicUsage[] | — | |
usage.output_tokens | body | integer | — |
Failure carries the platform error shape — see Errors.
Examples
CLI
SDK
HTTP
MCP
hanzo messages create.ts
.py
.go
.rs
.java
import { Configuration, AiApi } from 'hanzoai';
const api = new AiApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postMessages({ max_tokens: 0, messages: [{"content":"<content>","role":"<role>"}] });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AiApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AiApi(client).post_messages(max_tokens=0, messages=[{"content":"<content>","role":"<role>"}])cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.AiAPI.PostMessages(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, ai_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = ai_api::post_messages(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AiApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new AiApi(client).postMessages();curl -X POST https://api.hanzo.ai/v1/messages \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"max_tokens": 0,
"messages": [
{
"content": "<content>",
"role": "<role>"
}
]
}'MCP declares no tool for ai — tools/list on https://api.hanzo.ai/v1/mcp names the products it does reach. Use HTTP or an SDK.
Was this page useful?