Create chat completion
curl --request POST \
--url https://api.novita.ai/openai/v1/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "<string>",
"messages": [
{
"content": {
"type": "<string>",
"text": "<string>",
"image_url": "<string>",
"video_url": "<string>",
"modalities": [
"<string>"
],
"input_audio": {
"data": "<string>",
"format": "<string>"
}
},
"role": "<string>",
"name": "<string>"
}
],
"max_tokens": 123,
"stream": {},
"stream_options": {
"include_usage": true
},
"n": {},
"seed": {},
"frequency_penalty": {},
"presence_penalty": {},
"repetition_penalty": {},
"stop": {},
"temperature": {},
"top_p": {},
"top_k": {},
"min_p": {},
"logit_bias": {},
"logprobs": {},
"top_logprobs": {},
"tools": {
"type": "<string>",
"function": {
"name": "<string>",
"description": {},
"parameters": {},
"strict": true
}
},
"response_format": {
"type": "<string>",
"json_schema": {
"name": "<string>",
"description": {},
"schema": {},
"strict": true
}
},
"separate_reasoning": {},
"enable_thinking": {}
}
'import requests
url = "https://api.novita.ai/openai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"content": {
"type": "<string>",
"text": "<string>",
"image_url": "<string>",
"video_url": "<string>",
"modalities": ["<string>"],
"input_audio": {
"data": "<string>",
"format": "<string>"
}
},
"role": "<string>",
"name": "<string>"
}
],
"max_tokens": 123,
"stream": {},
"stream_options": { "include_usage": True },
"n": {},
"seed": {},
"frequency_penalty": {},
"presence_penalty": {},
"repetition_penalty": {},
"stop": {},
"temperature": {},
"top_p": {},
"top_k": {},
"min_p": {},
"logit_bias": {},
"logprobs": {},
"top_logprobs": {},
"tools": {
"type": "<string>",
"function": {
"name": "<string>",
"description": {},
"parameters": {},
"strict": True
}
},
"response_format": {
"type": "<string>",
"json_schema": {
"name": "<string>",
"description": {},
"schema": {},
"strict": True
}
},
"separate_reasoning": {},
"enable_thinking": {}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
model: '<string>',
messages: [
{
content: {
type: '<string>',
text: '<string>',
image_url: '<string>',
video_url: '<string>',
modalities: ['<string>'],
input_audio: {data: '<string>', format: '<string>'}
},
role: '<string>',
name: '<string>'
}
],
max_tokens: 123,
stream: {},
stream_options: {include_usage: true},
n: {},
seed: {},
frequency_penalty: {},
presence_penalty: {},
repetition_penalty: {},
stop: {},
temperature: {},
top_p: {},
top_k: {},
min_p: {},
logit_bias: {},
logprobs: {},
top_logprobs: {},
tools: {
type: '<string>',
function: {name: '<string>', description: {}, parameters: {}, strict: true}
},
response_format: {
type: '<string>',
json_schema: {name: '<string>', description: {}, schema: {}, strict: true}
},
separate_reasoning: {},
enable_thinking: {}
})
};
fetch('https://api.novita.ai/openai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.novita.ai/openai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'content' => [
'type' => '<string>',
'text' => '<string>',
'image_url' => '<string>',
'video_url' => '<string>',
'modalities' => [
'<string>'
],
'input_audio' => [
'data' => '<string>',
'format' => '<string>'
]
],
'role' => '<string>',
'name' => '<string>'
]
],
'max_tokens' => 123,
'stream' => [
],
'stream_options' => [
'include_usage' => true
],
'n' => [
],
'seed' => [
],
'frequency_penalty' => [
],
'presence_penalty' => [
],
'repetition_penalty' => [
],
'stop' => [
],
'temperature' => [
],
'top_p' => [
],
'top_k' => [
],
'min_p' => [
],
'logit_bias' => [
],
'logprobs' => [
],
'top_logprobs' => [
],
'tools' => [
'type' => '<string>',
'function' => [
'name' => '<string>',
'description' => [
],
'parameters' => [
],
'strict' => true
]
],
'response_format' => [
'type' => '<string>',
'json_schema' => [
'name' => '<string>',
'description' => [
],
'schema' => [
],
'strict' => true
]
],
'separate_reasoning' => [
],
'enable_thinking' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.novita.ai/openai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.novita.ai/openai/v1/chat/completions")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novita.ai/openai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}"
response = http.request(request)
puts response.read_body{
"choices": [
{
"finish_reason": "<string>",
"index": 123,
"message": {
"role": "<string>",
"content": {},
"reasoning_content": {}
}
}
],
"created": 123,
"id": "<string>",
"model": "<string>",
"object": "<string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123
}
}LLM API
Create chat completion
POST
/
openai
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
--url https://api.novita.ai/openai/v1/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "<string>",
"messages": [
{
"content": {
"type": "<string>",
"text": "<string>",
"image_url": "<string>",
"video_url": "<string>",
"modalities": [
"<string>"
],
"input_audio": {
"data": "<string>",
"format": "<string>"
}
},
"role": "<string>",
"name": "<string>"
}
],
"max_tokens": 123,
"stream": {},
"stream_options": {
"include_usage": true
},
"n": {},
"seed": {},
"frequency_penalty": {},
"presence_penalty": {},
"repetition_penalty": {},
"stop": {},
"temperature": {},
"top_p": {},
"top_k": {},
"min_p": {},
"logit_bias": {},
"logprobs": {},
"top_logprobs": {},
"tools": {
"type": "<string>",
"function": {
"name": "<string>",
"description": {},
"parameters": {},
"strict": true
}
},
"response_format": {
"type": "<string>",
"json_schema": {
"name": "<string>",
"description": {},
"schema": {},
"strict": true
}
},
"separate_reasoning": {},
"enable_thinking": {}
}
'import requests
url = "https://api.novita.ai/openai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"content": {
"type": "<string>",
"text": "<string>",
"image_url": "<string>",
"video_url": "<string>",
"modalities": ["<string>"],
"input_audio": {
"data": "<string>",
"format": "<string>"
}
},
"role": "<string>",
"name": "<string>"
}
],
"max_tokens": 123,
"stream": {},
"stream_options": { "include_usage": True },
"n": {},
"seed": {},
"frequency_penalty": {},
"presence_penalty": {},
"repetition_penalty": {},
"stop": {},
"temperature": {},
"top_p": {},
"top_k": {},
"min_p": {},
"logit_bias": {},
"logprobs": {},
"top_logprobs": {},
"tools": {
"type": "<string>",
"function": {
"name": "<string>",
"description": {},
"parameters": {},
"strict": True
}
},
"response_format": {
"type": "<string>",
"json_schema": {
"name": "<string>",
"description": {},
"schema": {},
"strict": True
}
},
"separate_reasoning": {},
"enable_thinking": {}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
model: '<string>',
messages: [
{
content: {
type: '<string>',
text: '<string>',
image_url: '<string>',
video_url: '<string>',
modalities: ['<string>'],
input_audio: {data: '<string>', format: '<string>'}
},
role: '<string>',
name: '<string>'
}
],
max_tokens: 123,
stream: {},
stream_options: {include_usage: true},
n: {},
seed: {},
frequency_penalty: {},
presence_penalty: {},
repetition_penalty: {},
stop: {},
temperature: {},
top_p: {},
top_k: {},
min_p: {},
logit_bias: {},
logprobs: {},
top_logprobs: {},
tools: {
type: '<string>',
function: {name: '<string>', description: {}, parameters: {}, strict: true}
},
response_format: {
type: '<string>',
json_schema: {name: '<string>', description: {}, schema: {}, strict: true}
},
separate_reasoning: {},
enable_thinking: {}
})
};
fetch('https://api.novita.ai/openai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.novita.ai/openai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'content' => [
'type' => '<string>',
'text' => '<string>',
'image_url' => '<string>',
'video_url' => '<string>',
'modalities' => [
'<string>'
],
'input_audio' => [
'data' => '<string>',
'format' => '<string>'
]
],
'role' => '<string>',
'name' => '<string>'
]
],
'max_tokens' => 123,
'stream' => [
],
'stream_options' => [
'include_usage' => true
],
'n' => [
],
'seed' => [
],
'frequency_penalty' => [
],
'presence_penalty' => [
],
'repetition_penalty' => [
],
'stop' => [
],
'temperature' => [
],
'top_p' => [
],
'top_k' => [
],
'min_p' => [
],
'logit_bias' => [
],
'logprobs' => [
],
'top_logprobs' => [
],
'tools' => [
'type' => '<string>',
'function' => [
'name' => '<string>',
'description' => [
],
'parameters' => [
],
'strict' => true
]
],
'response_format' => [
'type' => '<string>',
'json_schema' => [
'name' => '<string>',
'description' => [
],
'schema' => [
],
'strict' => true
]
],
'separate_reasoning' => [
],
'enable_thinking' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.novita.ai/openai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.novita.ai/openai/v1/chat/completions")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novita.ai/openai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}"
response = http.request(request)
puts response.read_body{
"choices": [
{
"finish_reason": "<string>",
"index": 123,
"message": {
"role": "<string>",
"content": {},
"reasoning_content": {}
}
}
],
"created": 123,
"id": "<string>",
"model": "<string>",
"object": "<string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123
}
}Creates a model response for the given chat conversation.
Request Headers
string
erforderlich
Enum:
application/jsonstring
erforderlich
Bearer authentication format, for example: Bearer {{API Key}}.
Request Body
string
erforderlich
The name of the model to use.
object[]
erforderlich
A list of messages comprising the conversation so far.
Anzeigen properties
Anzeigen properties
string | object[] | null
erforderlich
The contents of the message. content is required for all messages, and may be null for assistant messages with function calls.You may use the following parameters depending on the modality.
- Text content
- Image content
- Video content
- Audio content
Option 1:
You can use the string type to represent the text contents of the message.
Option 2:
Use an array of content parts, object[]. Detailed fields are as follows:
string
erforderlich
The type of the content part, in this case
text.string
erforderlich
The text content.
Only vision language models can be used.
An array of content parts, object[]. Detailed fields are as follows:
string
erforderlich
The type of the content part, in this case
image_url.Only models that support video can be used.
An array of content parts, object[]. Detailed fields are as follows:
string
erforderlich
The type of the content part, in this case
video_url.Only models that support audio can be used.
Output modality parameters:
string[]
Set the modality of the model output. Currently support two types:
["text"], ["text","audio"].
If ["text"] is passed in, the model only returns text content. If ["text","audio"] is passed in, the model will return both text content and audio content.
Default is ["text"].An array of content parts, object[]. Detailed fields are as follows:
string
erforderlich
The type of the content part, in this case
input_audio.string
erforderlich
The role of the messages author. One of system, user, or assistant.Enum:
system, user, assistantstring
The name of the author of this message. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
integer
erforderlich
The maximum number of tokens to generate in the completion.If the token count of your prompt (previous messages) plus max_tokens exceed the model’s context length, the behavior is depends on context_length_exceeded_behavior. By default, max_tokens will be lowered to fit in the context window instead of returning an error.
boolean | null
Standard:false
Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events (SSE) as they become available, with the stream terminated by a
data: [DONE] message.object | null
Options for streaming response. Only set this when you set stream: true.
Anzeigen properties
Anzeigen properties
boolean
If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value.
integer | null
Standard:1
How many completions to generate for each prompt.Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.Required range:
1 < x < 128integer | null
If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
number | null
Standard: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.Reasonable value is around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition.See also presence_penalty for penalizing tokens that have at least one appearance at a fixed rate.Required range:
-2 < x < 2number | null
Standard: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.Reasonable value is around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition.See also
frequency_penalty for penalizing tokens at an increasing rate depending on how often they appear.Required range: -2 < x < 2number | null
Applies a penalty to repeated tokens to discourage or encourage repetition. A value of 1.0 means no penalty, allowing free repetition. Values above 1.0 penalize repetition, reducing the likelihood of repeating tokens. Values between 0.0 and 1.0 reward repetition, increasing the chance of repeated tokens. For a good balance, a value of 1.2 is often recommended. Note that the penalty is applied to both the generated output and the prompt in decoder-only models.Required range:
0 < x < 2string | null
Up to 4 sequences where the API will stop generating further tokens. The returned text will contain the stop sequence.
number | null
Standard:1
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.We generally recommend altering this or
top_p but not both.Required range: 0 < x < 2number | null
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.Required range:
0 < x <= 1integer | null
Top-k sampling is another sampling method where the k most probable next tokens are filtered and the probability mass is redistributed among only those k next tokens. The value of k controls the number of candidates for the next token at each step during text generation.Required range:
1 < x < 128number | null
float that represents the minimum probability for a token to be considered, relative to the probability of the most likely token.Required range:
0 <= x <= 1map[string, integer] | null
Modify the likelihood of specified tokens appearing in the completion.Accepts a JSON object that maps tokens to an associated bias value from -100 to 100.
Mathematically, the bias is added to the logits generated by the model prior to
sampling. The exact effect will vary per model.For example, by setting
"logit_bias":{"1639": 6} will increase the likelihood of the token with token ID 1639.boolean | null
Standard:false
Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.
integer | null
An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
logprobs must be set to true if this parameter is used.Required range: 0 <= x <= 20object[] | null
A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.Learn more about function calling in the function calling guide.
Anzeigen properties
Anzeigen properties
string
erforderlich
The type of the tool.Supported types:
functionobject
erforderlich
Anzeigen properties
Anzeigen properties
string
erforderlich
The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
string | null
A description of what the function does, used by the model to choose when and how to call the function.
object | null
The parameters the functions accepts, described as a JSON Schema object. See the JSON Schema reference for documentation about the format.
boolean
Standard:false
Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field.
object | null
Allows to force the model to produce specific output format.Setting to
{ "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema.Setting to { "type": "json_object" } enables the older JSON mode, which ensures the message the model generates is valid JSON. Using json_schema is preferred for models that support it.Anzeigen properties
Anzeigen properties
string
Standard:"text"
erforderlich
Enum:
text, json_object, json_schemaobject | null
JSON Schema response format. Used to generate structured JSON responses.Only supported when
type is set to json_schema, and also required when type is set to json_schema.Please learn more in the Structured Outputs guide.Anzeigen properties
Anzeigen properties
string
erforderlich
The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
string | null
A description of what the response format is for, used by the model to determine how to respond in the format.
object | null
The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.Supported types:
string, number, integer, boolean, array, object, enum, anyOf.boolean
Standard:false
Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true.If you turn on Structured Outputs by supplying
strict: true and call the API with an unsupported JSON Schema, you will receive an error.boolean | null
Standard:false
Whether to separate the reasoning from the “content” into “reasoning_content” field.Supported models:
deepseek/deepseek-r1-turbo
boolean | null
Standard:true
Controls the switches between thinking and non-thinking modes.Supported models:
- zai-org/glm-4.5
- deepseek/deepseek-v3.1
- deepseek/deepseek-v3.1-terminus
- deepseek/deepseek-v3.2-exp
Response
object[]
erforderlich
The list of chat completion choices.
Anzeigen properties
Anzeigen properties
string
erforderlich
The reason the model stopped generating tokens. This will be “stop” if the model hit a natural stop point or a provided stop sequence, or “length” if the maximum number of tokens specified in the request was reached.Available options:
stop, lengthinteger
erforderlich
The index of the chat completion choice.
object
erforderlich
integer
erforderlich
The Unix time in seconds when the response was generated.
string
erforderlich
A unique identifier of the response.
string
erforderlich
The model used for the chat completion.
string
erforderlich
The object type, which is always
chat.completion.object
Usage statistics.For streaming responses, usage field is included in the very last response chunk returned.
Zuletzt geändert am 15. Mai 2026