Skip to main content
The Chat Completions endpoint allows you to generate text responses using the distributed language models in the Fortytwo network. It supports both standard responses and streaming via Server-Sent Events (SSE).

Create Chat Completion

Generate a response to a conversation using a specified network model’s preset.

Endpoint

Request Body

model
string
required
ID of the model to use (from /v1/models).
messages
array
required
List of messages in the conversation.
stream
boolean
default:"false"
Enable Server-Sent Events streaming.

Message Format

Each message in the messages array should have:
role
string
required
One of: system | user | assistant.
content
string
required
The content of the message.

Response Modes

In standard mode, the API returns a complete response once generation is finished.

Example Request

Response Format

Response Fields

id
string
Unique identifier for the completion.
object
string
Always chat.completion.
created
integer
Unix timestamp of creation.
model
string
Model used for generation.
choices
array
List of completion choices.
usage
object
Token usage information.

OpenAI SDK Integration

The Fortytwo API is fully compatible with the OpenAI Python and Node.js SDKs:

Preview Rate Limiting

Chat completion requests are subject to rate limits while in Preview. See ‘Preview Limits & Quotas’ for more details.

Error Responses

Common error responses for chat completions can be found in ‘Errors’.

Next Steps