Chat completions
Create a model response for a conversation. Supports streaming and tool calling.
/v1/chat/completionsCreate a chat completion.
Auth: Bearer keyZ1, Z1 Code and H1 are restricted to the private pilot, and project-zero to enrolled developers. Any other account that sends those ids is refused (400 model_not_found or 403 zero_entitlement_required).
Request body
modelstring · requiredz1, z1-code, h1 or project-zero. The aliases tessen/z1, tessen/z1-code and tessen/h1 are also accepted. Always send one.
messagesarray · requiredAt least one message. Each has a role (system, user, assistant, tool) and content. An assistant message may carry tool_calls; a tool message carries tool_call_id.
max_tokensintegerMaximum output tokens. Reasoning tokens count toward it. Up to 16384 on the commercial families; above that the request is refused with 413 request_too_large.
max_completion_tokensintegerAccepted as an alternative to max_tokens.
streambooleantrue for server-sent events. Default false. See Streaming.
toolsarrayFunctions the model may call, in OpenAI type: "function" format.
tool_choicestring | objectauto, none, or a specific function.
temperature, top_p, stop, n, usernumber, number, string|array, integer, stringAccepted in OpenAI format. n returns that many choices (verified on Z1).
presence_penalty, frequency_penaltynumberAccepted.
response_format, logprobs, top_logprobs—Not supported. These fields are accepted without error and ignored: output is not constrained to a format and no log probabilities are returned.
Fields not listed here are not part of the contract, even if the request is accepted. In particular, do not send program, level or zero_alias.
Example
curl https://api.tessen.ai/v1/chat/completions \ -H "Authorization: Bearer $TESSEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "z1", "max_tokens": 256, "messages": [{"role": "user", "content": "Reply with the single word: ok"}] }'import osimport requests response = requests.post( "https://api.tessen.ai/v1/chat/completions", headers={"Authorization": f"Bearer {os.environ['TESSEN_API_KEY']}"}, json={ "model": "z1", "max_tokens": 256, "messages": [{"role": "user", "content": "Reply with the single word: ok"}], }, timeout=120,)response.raise_for_status()body = response.json()print(body["choices"][0]["message"]["content"])print(body["usage"])const response = await fetch("https://api.tessen.ai/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.TESSEN_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ model: "z1", max_tokens: 256, messages: [{ role: "user", content: "Reply with the single word: ok" }], }),});if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);const body = await response.json();console.log(body.choices[0].message.content);console.log(body.usage);Response
{ "id": "b9f325286dab4acc903ac13dd4836fe2", "object": "chat.completion", "created": 1793282245, "model": "z1", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "ok", "name": null, "tool_calls": null, "tool_call_id": null, "reasoning": null, "reasoning_content": null }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 11, "completion_tokens": 2, "total_tokens": 13 }}id, object, created, modelstring, string, integer, stringIdentifier, chat.completion, Unix seconds, and the model id you requested (the underlying model is not named).
choices[].message.contentstringThe answer. May be empty when finish_reason is length or tool_calls.
choices[].message.tool_callsarray | nullFunction calls the model wants made. Each has id, type, and function.name and function.arguments (a JSON string).
choices[].message.reasoning, reasoning_contentstring | nullPresent on every message. Populated only when a reasoning model produced reasoning text. Not part of the stable contract.
choices[].finish_reasonstringstop, length (output limit reached) or tool_calls.
usageobjectprompt_tokens, completion_tokens and total_tokens. Reasoning tokens are included in completion_tokens.
Errors
| Status · code | When |
|---|---|
400 model_not_found | The model id is not in the registry, or your account cannot call that family. |
401 authentication_required / invalid_api_key | Missing or invalid key. |
402 insufficient_credits | The wallet cannot cover the request. Nothing is charged. |
403 zero_entitlement_required | project-zero without enrollment. |
413 request_too_large | max_tokens exceeds the model's limit. |
| 422 | The body is invalid, for example no messages. Body is { "detail": [...] }. |
503 zero_capacity_unavailable | A ZERO limit closed. See Errors. |