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

Addresshttps://api.hanzo.ai/v1/ai/mcp/chat
MethodPOST
OperationaiChat
AuthAuthorization: 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).

FieldInTypeRequiredDescription
max_tokensbodyinteger (int64)—MaxTokens bounds the answer in tokens; 0 leaves it to the model.
modelbodystring—Model is the model to answer, by id (zen5, enso, kai, anthropic/claude-sonnet-4.5 — aiModels lists them).
promptbodystring—Prompt is what to ask.
systembodystring—System is the system message ahead of the prompt, when set.

Response

StatusBodyMeaning
200aiChatok
defaultproblem-detailsrefused

200 body — 10 fields.

FieldInTypeAlwaysDescription
answerbodystring—Answer is the model's reply.
modelbodystring—Model is the model asked: the caller's, or the default when it named none.
receiptbodyaiReceipt—
receipt.classbodystring—Class is the model's class as billed: premium, ours or free (X-Hanzo-Usage-Class).
receipt.fallbackbodystring—Fallback is the model that answered in place of the one asked, in limited mode (X-Hanzo-Fallback).
receipt.paid_bybodystring—PaidBy is plan, credits or free (X-Hanzo-Paid-By); absent when the answer named no payer, as a free model's does.
receipt.reasonbodystring—Reason is the refusal code that sent the request to the fallback (X-Hanzo-Usage-Reason).
receipt.routedbodystring—Routed is the model auto resolved to (X-Routed-Model).
receipt.servedbodystring—Served is the model that answered (X-Hanzo-Served).
receipt.usagebodystring—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.


AI API · All Hanzo APIs · Interactive reference

Was this page useful?