Skip to main content
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

string
required
A model ID from Models or GET /v1/models. An unknown ID returns 404 model_not_found.
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.
boolean
default:"false"
true returns the response as server-sent events — see Streaming.
boolean
With stream: true, adds a final chunk with usage — see Streaming.
integer
default:"1"
Only 1 is accepted.
boolean
default:"false"
Only false is accepted. true returns 400 zdr_storage_not_supported — see Data handling.
The fields for tool calling and structured output are described below.

Message roles

Do not send reasoning, reasoning_details or refusal back in an assistant message. The request fails with 400 invalid_request. Remove these fields before you add a reply to the conversation.

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 in tools. 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 in choices[].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:
  1. The assistant message with the tool_calls.
  2. One tool message per call, with the call’s id as tool_call_id and the result as content.
In a stream, 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

Set response_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/models and POST /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.
Last modified on October 3, 2026