POST https://api.fortytwo.network/v1/chat/completions generates a response to a conversation. Authentication is described on Get access.
Send a request
Request fields
array
required
The conversation, in order. Each entry has a
role and content, and optionally a name (1–64 letters, digits, _ or -) — see Message roles. An assistant entry can also carry tool_calls, and a tool entry carries tool_call_id. Other fields return 400 invalid_request.integer
The maximum number of tokens to generate. From 1 to the model’s max output; the default is the model’s max output.
max_completion_tokens is accepted as an alternative name. Send only one of the two.string
default:"medium"
How much the model reasons before it answers:
none, minimal, low, medium, high, xhigh or max. none turns reasoning off.integer
default:"1"
Only
1 is accepted.boolean
default:"false"
Only
false is accepted. true returns 400 zdr_storage_not_supported — see Data handling.Message roles
Message content
content is a string or an array of content parts. A user message can also carry image_url parts — see Image input. Other part types, such as audio, video or file, return 400 unsupported_content_type.
Sampling controls
A sampling parameter works only with a model that supports it; Models lists them.GET /v1/models does not report them. A parameter that is off, a value outside the range below, or a parameter sent twice returns 400 invalid_request. Values are never clamped. Leave a parameter out to use the model’s default.
Tool calling
Describe your functions intools. The model returns the calls it wants to make. Your application runs them and sends the results back in tool messages. Fortytwo does not call tools and does not store tool definitions, arguments or results.
array
The functions the model may call, up to 128. Each entry is
{ "type": "function", "function": { ... } }, with a name (1–64 letters, digits, _ or -), an optional description, the parameters as a JSON Schema object, and an optional strict boolean.string or object
auto lets the model decide, required makes it call at least one tool, and none stops it calling any. To force one function, send { "type": "function", "function": { "name": "<name>" } }.boolean
Allow more than one call in one message.
Send the results back
Each call inchoices[].message.tool_calls has an id, a function name and arguments as a JSON string. Run the function. Then send the request again with the same tools, and add to messages:
- The assistant message with the
tool_calls. - One
toolmessage per call, with the call’sidastool_call_idand the result ascontent.
arguments arrive in pieces in choices[].delta.tool_calls. Join the pieces of each call by its index, and parse them when the stream ends.
Structured output
Setresponse_format to get JSON in choices[].message.content.
object
{ "type": "text" } is the default. { "type": "json_object" } returns a JSON object. { "type": "json_schema", "json_schema": { "name": "...", "strict": true, "schema": { ... } } } returns JSON that matches your schema. strict must be true.Not supported
- Fields not described on this page or on Streaming return
400 invalid_request. The full list is on OpenAI compatibility. Check that your client library does not add them. - Endpoints other than
GET /v1/modelsandPOST /v1/chat/completions— see API conventions.
Response
string
An opaque identifier for this completion.
string
chat.completion for a single response. A streamed response carries chat.completion.chunk instead.integer
When the completion was created, as a Unix timestamp.
string
The model ID from the request.
array
The generated results. Each entry carries
index, message and finish_reason.object
The assistant message, with its
role, its content and, when the model calls tools, tool_calls.array
Present when the model calls tools. Each entry has an
id, type: "function", and a function with name and arguments (a JSON string) — see Tool calling.string
The reasoning before the answer, when the model reasons. Its tokens are counted in
usage.completion_tokens and billed as output. Do not send it back in later requests.array
Structured reasoning entries, when the model reasons. Their shape can change. Do not send them back in later requests.
object
prompt_tokens, completion_tokens and total_tokens. Always present on a non-streaming response — see Streaming for streams.integer
Prompt tokens served from the prompt cache.