Call a model with the API
Create a Platform API key
Sign in to the Platform with your Tenzro Labs account and open the API keys page. Create a key with the inference permission. The secret starts with tzl_ and is shown once; the Platform stores only a hash.
export TENZRO_API_KEY="tzl_..."Choose a model by id
GET /v1/models lists every model that can be called right now, with its endpoint and the machines serving it. It needs no key.
curl https://api.tenzro.xyz/v1/models{
"object": "list",
"default_machine": "tenzro-partner-cluster",
"data": [
{
"id": "qwen3.5-4b",
"object": "model",
"owned_by": "tenzro-labs",
"name": "Qwen 3.5 4B",
"modality": "text",
"endpoint": "/v1/chat/completions",
"context_length": 131072,
"max_output_tokens": 2048,
"features": ["tools"],
"machines": [{ "id": "tenzro-partner-cluster", "name": "Tenzro Partner Cluster", "region": "Europe" }]
}
]
}Language models have endpoint set to /v1/chat/completions. Use the id as the model field in every request.
Send a chat completion with curl
The request and response follow the OpenAI chat completions format.
curl https://api.tenzro.xyz/v1/chat/completions \
-H "Authorization: Bearer $TENZRO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.5-4b",
"messages": [{"role": "user", "content": "Write a haiku about GPUs"}]
}'modelmessagesstreammax_tokenstemperature, top_p, stop, seedtools, tool_choiceenable_thinkingmachineUse the OpenAI Python SDK
Point the OpenAI client at the Tenzro Labs base URL and pass your Platform key.
pip install openaiimport os
from openai import OpenAI
client = OpenAI(base_url="https://api.tenzro.xyz/v1", api_key=os.environ["TENZRO_API_KEY"])
reply = client.chat.completions.create(
model="qwen3.5-4b",
messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)Use the OpenAI JavaScript SDK
npm install openaiimport OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.tenzro.xyz/v1", apiKey: process.env.TENZRO_API_KEY });
const reply = await client.chat.completions.create({
model: "qwen3.5-4b",
messages: [{ role: "user", content: "Hello" }],
});
console.log(reply.choices[0].message.content);node chat.mjsChoose where it runs
machine is optional. Without it, the request runs on tenzro-partner-cluster. The machine ids for a model are in its machines list from GET /v1/models.
curl https://api.tenzro.xyz/v1/chat/completions \
-H "Authorization: Bearer $TENZRO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.5-4b",
"machine": "tenzro-partner-cluster",
"messages": [{"role": "user", "content": "Hello"}]
}'Python
The OpenAI SDK sends fields it does not know through extra_body.
reply = client.chat.completions.create(
model="qwen3.5-4b",
messages=[{"role": "user", "content": "Hello"}],
extra_body={"machine": "tenzro-partner-cluster"},
)JavaScript
const reply = await client.chat.completions.create({
model: "qwen3.5-4b",
machine: "tenzro-partner-cluster",
messages: [{ role: "user", content: "Hello" }],
});Stream the reply
Set stream to true. Chunks arrive as OpenAI server-sent events, and the last chunk carries the token usage.
stream = client.chat.completions.create(
model="qwen3.8-27b",
messages=[{"role": "user", "content": "Explain proof of stake in two sentences"}],
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="", flush=True)const stream = await client.chat.completions.create({
model: "qwen3.8-27b",
messages: [{ role: "user", content: "Explain proof of stake in two sentences" }],
stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");curl -N https://api.tenzro.xyz/v1/chat/completions \
-H "Authorization: Bearer $TENZRO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3.5-4b", "messages": [{"role": "user", "content": "Hello"}], "stream": true}'Handle errors
Errors use the OpenAI shape, {"error": {"message", "type", "code"}}, with a matching HTTP status.
wrong_endpointmissing_api_key · invalid_api_keyinsufficient_creditkey_lacks_inference_permissionmodel_not_found · machine_not_foundmachine_unreachable · machine_errorno_capacity502 and 503 with exponential backoff. The other errors will not succeed on retry. Every price is zero on testnet.