Text completion

POST /v1/complete runs a conversation through a tier's ladder.

Request#

FieldMeaning
tierRequired. The tier name, see Tiers and the fallback ladder
messagesA non-empty array of {role, content} where role is system, user or assistant. Use this or prompt
promptA non-empty string, sent as one user message
max_tokens1 to 32000, default 512. Values outside are clamped
temperature0 to 2, default 0.3. Values outside are clamped
subjectThe end client's wallet, <product>:<what>:<who>, up to 200 characters. Enables the per-client limit. Without it only the product limit counts
request_idYour own id, up to 100 characters, stored in the journal
metadataAn 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#

FieldMeaning
contentThe text, or null if the model answered with empty text. That is an answer, not an error
model, pool, tierWho answered
rungThe position in the ladder of the model that answered. Above 0 means the primary model did not answer
attemptsEvery rung tried or skipped: rung, model, pool, outcome, httpStatus, latencyMs, tries, token counts and detail
totalLatencyMsThe time for the whole ladder
tool_calls, finish_reasonOnly 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, parameters is 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 requires tools. It is forwarded as is and the upstream may not enforce required or a named function, so do not rely on it.
  • In messages, an assistant message may carry tool_calls: [{id, type: "function", function: {name, arguments}}] (up to 32 calls, arguments a 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.