Text completion
POST /v1/complete runs a conversation through a tier's ladder.
Request#
| Field | Meaning |
|---|---|
tier | Required. The tier name, see Tiers and the fallback ladder |
messages | A non-empty array of {role, content} where role is system, user or assistant. Use this or prompt |
prompt | A non-empty string, sent as one user message |
max_tokens | 1 to 32000, default 512. Values outside are clamped |
temperature | 0 to 2, default 0.3. Values outside are clamped |
subject | The end client's wallet, <product>:<what>:<who>, up to 200 characters. Enables the per-client limit. Without it only the product limit counts |
request_id | Your own id, up to 100 characters, stored in the journal |
metadata | An object up to 4 KB, such as a session or trace id, stored in the journal |
A traceparent header (W3C trace context) makes the journal entry a child of your span. A malformed one is ignored. The body is limited to 1,000,000 bytes; a larger one gives 400 bad_request.
Response#
| Field | Meaning |
|---|---|
content | The text, or null if the model answered with empty text. That is an answer, not an error |
model, pool, tier | Who answered |
rung | The position in the ladder of the model that answered. Above 0 means the primary model did not answer |
attempts | Every rung tried or skipped: rung, model, pool, outcome, httpStatus, latencyMs, tries, token counts and detail |
totalLatencyMs | The time for the whole ladder |
tool_calls, finish_reason | Only when the request used tools |
An attempt's outcome is ok, exhausted, rejected, retired, error, timeout, unauthorized or skipped.
Tool calls#
You can pass OpenAI-form tools. The loop stays in your product: you run the tool and send the result back in the next request.
tools: 1 to 64 items{type: "function", function: {name, description?, parameters?}}. A name matches^[A-Za-z0-9_-]{1,64}$and is unique. A description is up to 4000 characters,parametersis a JSON Schema object. Each tool is up to 32 KB, all together up to 256 KB.tool_choice:"auto","none","required"or{type: "function", function: {name}}. It requirestools. It is forwarded as is and the upstream may not enforcerequiredor a named function, so do not rely on it.- In
messages, an assistant message may carrytool_calls: [{id, type: "function", function: {name, arguments}}](up to 32 calls,argumentsa JSON string up to 64 KB), and a message{role: "tool", tool_call_id, content}answers one.
When tools are used, the response adds tool_calls (an empty array if the model asked for none) and finish_reason. A reply with tool calls and no text is a success with content: null.
Only models that pass tools through are tried; others appear in attempts as skipped with detail: "no tool support". If no model in the tier can, the answer is 400 tools_unsupported; use another tier. A malformed field gives 400 bad_request with detail naming it.