curl -X POST https://api-llm.sunra.ai/v1/chat/completions \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-2.5-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "google/gemini-2.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris.",
"refusal": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33,
"prompt_tokens_details": null,
"completion_tokens_details": null
}
}
LLM
Create a chat completion
POST
/
v1
/
chat
/
completions
curl -X POST https://api-llm.sunra.ai/v1/chat/completions \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-2.5-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "google/gemini-2.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris.",
"refusal": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33,
"prompt_tokens_details": null,
"completion_tokens_details": null
}
}
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.Show message types
Show message types
- SystemMessage
- UserMessage
- DeveloperMessage
- AssistantMessage
- ToolResponseMessage
string
required
Value:
system.string | object[]
required
The system message content. Can be a string or array of text content parts.
string
Optional name for the system message.
string
required
Value:
user.string | object[]
required
The user message content. Can be a string or array of content parts.
Show content part types
Show content part types
- text
- image_url
- input_audio
- video_url
- file
string
required
Value:
text.string
required
The text content.
string
required
Value:
image_url.string
required
Value:
input_audio.string
required
Value:
video_url.string
Optional name for the user.
string
required
Value:
developer.string | object[]
required
The developer message content. Can be a string or array of text content parts.
string
Optional name for the developer message.
string
required
Value:
assistant.string | object[] | null
The assistant message content. Can be a string, array of content parts, or null (when tool_calls are present).
string
Optional name for the assistant.
object[]
string | null
Refusal message if content was refused.
string | null
Reasoning output text.
object[]
Detailed reasoning information for extended thinking models.
Show reasoning detail types
Show reasoning detail types
- summary
- encrypted
- text
string
required
Value:
reasoning.summary.string
required
The reasoning summary text.
string | null
Reasoning detail ID.
string | null
Format. Supported values:
unknown, openai-responses-v1, azure-openai-responses-v1, xai-responses-v1, anthropic-claude-v1, google-gemini-v1.string
required
Value:
reasoning.encrypted.string
required
Encrypted reasoning data.
string | null
Reasoning detail ID.
string | null
Format identifier.
object[]
Generated images from image generation models. Each item has
image_url.url.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
object
An object specifying the format that the model must output.
Show format types
Show format types
- text
- json_object
- json_schema
- grammar
string
required
Value:
text.string
required
Value:
json_object.string
required
Value:
json_schema.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.
Show properties
Show properties
string
required
The type of the tool. Value:
function.object
required
The function definition.
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
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.Show properties
Show properties
number
The index of the choice in the list of choices.
string
The reason the model stopped generating tokens. Possible values:
stop, length, tool_calls, content_filter, error.object
A chat completion message generated by the model.
Show properties
Show properties
string
Always
assistant.string | null
The text contents of the message. Null when tool_calls are present.
object[]
string | null
Refusal message if the content was refused.
string | null
Reasoning output text.
object[]
Detailed reasoning information for extended thinking models.
Show reasoning detail types
Show reasoning detail types
- summary
- encrypted
- text
string
Value:
reasoning.summary.string
The reasoning summary text.
string | null
Detail ID.
string | null
Format identifier.
string
Value:
reasoning.encrypted.string
Encrypted reasoning data.
string | null
Detail ID.
string | null
Format identifier.
object[]
Generated images. Each item contains
image_url.url.object
Usage statistics for the completion request.
Show properties
Show properties
number
Number of tokens in the prompt.
number
Number of tokens in the generated completion.
number
Total number of tokens used in the request (prompt + completion).
object | null
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.curl -X POST https://api-llm.sunra.ai/v1/chat/completions \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-2.5-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "google/gemini-2.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris.",
"refusal": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33,
"prompt_tokens_details": null,
"completion_tokens_details": null
}
}
⌘I