DEVELOPER GUIDE
First API request
Send one chat completion, read the answer and the usage, and know what each field means.
A first request needs the key in TESSEN_API_KEY and a model your account may call. The example uses z1; use project-zero if you are enrolled in ZERO Alpha instead.
CHAT COMPLETION
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);The request
modelstring · requiredThe model id: z1, z1-code, h1 or project-zero.
messagesarray · requiredThe conversation so far, oldest first. Each item has a role (system, user, assistant or tool) and content.
max_tokensintegerThe most output tokens to generate. Always set it; reasoning tokens count toward it.
The response
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 }}choices[0].message.contentstringThe answer.
choices[0].finish_reasonstringstop when the model finished, length when max_tokens ran out, tool_calls when it asked for a function.
usageobjectprompt_tokens, completion_tokens, total_tokens. On Tessen's families the cost of the request is the sum of these at the published price.
What can fail
- 401 — the key is missing or invalid.
- 400
model_not_found— the model id is not one your account can call. - 402
insufficient_credits— the wallet cannot cover the request; nothing was charged. - 413
request_too_large—max_tokensis above the model's limit. - 422 — the body is not valid (for example no
messages).