Skip to main content
POST
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes, text, images, audio, video, files, function calling, reasoning, and structured outputs. Compatible with the OpenAI Chat Completions API format.

Authentication

string
required
Bearer token. Use your API key as the bearer token in the Authorization header.Format: Bearer <SUNRA_KEY>

Request

This endpoint expects an object.
object[]
required
List of messages for the conversation. Each message has a role and content.
string
required
The model to use for the completion. Browse available models at sunra.ai/models.
object
Optional provider routing preferences. Omit for automatic routing. See Provider routing for supported fields and provider discovery.
boolean
default:false
If set to true, partial message deltas will be sent as server-sent events (SSE). Streams are subject to an idle timeout and a lifetime ceiling — see Output limits and stream lifetime.
number | null
Maximum tokens in completion. Replaces max_tokens as the preferred parameter. On providers that do not honor this field the gateway translates it into max_tokens; when both are set, the smaller one applies. See Output limits.
number | null
Maximum tokens in completion. Deprecated — use max_completion_tokens instead. Note: some providers enforce a minimum of 16. A value above the model’s own output ceiling is rejected with 400 rather than reduced.
number | null
default:1
Sampling temperature between 0 and 2. Higher values like 0.8 make output more random, lower values like 0.2 make it more focused and deterministic.
number | null
default:1
Nucleus sampling parameter (0-1). An alternative to temperature sampling where the model considers the tokens with top_p probability mass.
number | null
default:0
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
number | null
default:0
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.
string | string[]
Up to 4 sequences where the API will stop generating further tokens.
integer
default:1
How many chat completion choices to generate for each input message.
boolean | null
default:false
Whether to return log probabilities of the output tokens.
number | null
An integer between 0 and 20 specifying the number of most likely tokens to return at each token position. logprobs must be set to true if this parameter is used.
object | null
Token logit bias adjustments. Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.
object
Configuration options for reasoning models.
object
An object specifying the format that the model must output.
integer | null
If specified, the system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
object[]
A list of tools the model may call.
string | object
Controls which (if any) tool is called by the model. none means no tool calls. auto means the model decides. required means the model must call a tool. Can also specify a particular function.
boolean | null
default:true
Whether to enable parallel function calling during tool use.
string[]
Output modalities for the response. Supported values: text, image, audio.
object
Key-value pairs for additional object information. Maximum 16 pairs, 64 character keys, 512 character values.
object
Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
string
A unique identifier representing your end-user, which can help monitor and detect abuse.

Response

Successful chat completion response.
string
A unique identifier for the chat completion.
string
The object type. Always chat.completion.
number
The Unix timestamp (in seconds) of when the chat completion was created.
string
The model used for the chat completion.
object[]
A list of chat completion choices. Can be more than one if n is greater than 1.
object
Usage statistics for the completion request.
string | null
This fingerprint represents the backend configuration that the model runs with. Can be used with the seed parameter to understand when backend changes have been made.