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
A model ID from Models or
GET /v1/models. An unknown ID returns 404 model_not_found.The conversation, in order. Each entry has a
role and content (an assistant entry with tool_calls can omit content or set it to null), 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.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.How much the model reasons before it answers:
none, minimal, low, medium, high, xhigh or max. none turns reasoning off.true returns the response as server-sent events — see Streaming.With
stream: true, adds a final chunk with usage — see Streaming.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
Sampling parameters are sent to the model. Models lists the ones each model applies; a model may ignore or refuse one it does not list.GET /v1/models does not report them. 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.
The functions the model may call, up to 128. Each entry is
{ "type": "function", "function": { ... } }, with a name (1–64 letters, digits, _ or -, unique within tools), the parameters as a JSON Schema object (required), an optional description and an optional strict boolean.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>" } }.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.
{ "type": "text" } is the default. { "type": "json_object" } returns a JSON object. { "type": "json_schema", "json_schema": { "name": "...", "description": "...", "strict": true, "schema": { ... } } } returns JSON that matches your schema. description is optional; strict must be true.Not supported
- Fields not described on this page or on Streaming are accepted and ignored: they have no effect. A few OpenAI fields are accepted only with values that change nothing. The full list is on OpenAI compatibility.
- Endpoints other than
GET /v1/modelsandPOST /v1/chat/completions— see API conventions.
Response
chat.completion for a single response. A streamed response carries chat.completion.chunk instead.The assistant message, with its
role, its content and, when the model calls tools, tool_calls.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.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.Structured reasoning entries, when the model reasons. Their shape can change. Do not send them back in later requests.
prompt_tokens, completion_tokens and total_tokens. Always present on a non-streaming response — see Streaming for streams.