Create chat — POST /v1/ai/mcp/chat
Asks one model one prompt and answers the reply, which model served it and who paid.
POST /v1/ai/mcp/chat
| Address | https://api.hanzo.ai/v1/ai/mcp/chat |
| Method | POST |
| Operation | aiChat |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Asks one model one prompt and answers the reply, which model served it and who paid. The call is the caller's own POST /v1/chat/completions, run as the caller, so it is gated, billed and refused exactly as that route is; a refusal names its code and what lifts it, never an amount. An empty model asks the deployment's default Hanzo model.
Request
4 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
max_tokens | body | integer (int64) | — | MaxTokens bounds the answer in tokens; 0 leaves it to the model. |
model | body | string | — | Model is the model to answer, by id (zen5, enso, kai, anthropic/claude-sonnet-4.5 — aiModels lists them). |
prompt | body | string | — | Prompt is what to ask. |
system | body | string | — | System is the system message ahead of the prompt, when set. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | aiChat | ok |
default | problem-details | refused |
200 body — 10 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
answer | body | string | — | Answer is the model's reply. |
model | body | string | — | Model is the model asked: the caller's, or the default when it named none. |
receipt | body | aiReceipt | — | |
receipt.class | body | string | — | Class is the model's class as billed: premium, ours or free (X-Hanzo-Usage-Class). |
receipt.fallback | body | string | — | Fallback is the model that answered in place of the one asked, in limited mode (X-Hanzo-Fallback). |
receipt.paid_by | body | string | — | PaidBy is plan, credits or free (X-Hanzo-Paid-By); absent when the answer named no payer, as a free model's does. |
receipt.reason | body | string | — | Reason is the refusal code that sent the request to the fallback (X-Hanzo-Usage-Reason). |
receipt.routed | body | string | — | Routed is the model auto resolved to (X-Routed-Model). |
receipt.served | body | string | — | Served is the model that answered (X-Hanzo-Served). |
receipt.usage | body | string | — | Usage is where that class stands for the payer: ok, near or limited (X-Hanzo-Usage). |
Failure carries the platform error shape — see Errors.
Examples
hanzo has no subcommand for this operation — the CLI serves only what cloud's live route table confirms. Use HTTP or an SDK.
import { Configuration, AiApi } from 'hanzoai';
const api = new AiApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.aiChat({ max_tokens: 0, model: "<model>" });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).ai_chat(max_tokens=0, model="<model>")cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.AiAPI.AiChat(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::ai_chat(&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).aiChat();curl -X POST https://api.hanzo.ai/v1/ai/mcp/chat \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"max_tokens": 0,
"model": "<model>"
}'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.