curl --request POST \
--url https://api.example.com/v1/chat/completions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": false,
"top_logprobs": 0,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": {
"json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
}
},
"seed": 0,
"stop": [],
"stream": false,
"stream_options": {
"include_usage": true,
"continuous_usage_stats": false
},
"temperature": 123,
"top_p": 123,
"tools": [
{
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
},
"type": "function"
}
],
"tool_choice": "none",
"include_reasoning": true,
"parallel_tool_calls": true,
"user": "<string>",
"use_beam_search": false,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"length_penalty": 1,
"stop_token_ids": [],
"include_stop_str_in_output": false,
"ignore_eos": false,
"min_tokens": 0,
"skip_special_tokens": true,
"spaces_between_special_tokens": true,
"truncate_prompt_tokens": 4611686018427388000,
"prompt_logprobs": 123,
"allowed_token_ids": [
123
],
"bad_words": [
"<string>"
],
"echo": false,
"add_generation_prompt": true,
"continue_final_message": false,
"add_special_tokens": false,
"documents": [
{}
],
"chat_template": "<string>",
"chat_template_kwargs": {},
"mm_processor_kwargs": {},
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": [
"<string>"
],
"grammar": "<string>",
"json_object": true,
"disable_fallback": false,
"disable_any_whitespace": false,
"disable_additional_properties": false,
"whitespace_pattern": "<string>",
"structural_tag": "<string>",
"_backend": "<string>",
"_backend_was_auto": false
},
"priority": 0,
"request_id": "<string>",
"return_tokens_as_token_ids": true,
"return_token_ids": true,
"cache_salt": "<string>",
"kv_transfer_params": {},
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
}
}
'import requests
url = "https://api.example.com/v1/chat/completions/"
payload = {
"messages": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": False,
"top_logprobs": 0,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": { "json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": True
} },
"seed": 0,
"stop": [],
"stream": False,
"stream_options": {
"include_usage": True,
"continuous_usage_stats": False
},
"temperature": 123,
"top_p": 123,
"tools": [
{
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
},
"type": "function"
}
],
"tool_choice": "none",
"include_reasoning": True,
"parallel_tool_calls": True,
"user": "<string>",
"use_beam_search": False,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"length_penalty": 1,
"stop_token_ids": [],
"include_stop_str_in_output": False,
"ignore_eos": False,
"min_tokens": 0,
"skip_special_tokens": True,
"spaces_between_special_tokens": True,
"truncate_prompt_tokens": 4611686018427388000,
"prompt_logprobs": 123,
"allowed_token_ids": [123],
"bad_words": ["<string>"],
"echo": False,
"add_generation_prompt": True,
"continue_final_message": False,
"add_special_tokens": False,
"documents": [{}],
"chat_template": "<string>",
"chat_template_kwargs": {},
"mm_processor_kwargs": {},
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": ["<string>"],
"grammar": "<string>",
"json_object": True,
"disable_fallback": False,
"disable_any_whitespace": False,
"disable_additional_properties": False,
"whitespace_pattern": "<string>",
"structural_tag": "<string>",
"_backend": "<string>",
"_backend_was_auto": False
},
"priority": 0,
"request_id": "<string>",
"return_tokens_as_token_ids": True,
"return_token_ids": True,
"cache_salt": "<string>",
"kv_transfer_params": {},
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{content: '<string>', role: '<string>', name: '<string>'}],
model: '<string>',
frequency_penalty: 0,
logit_bias: {},
logprobs: false,
top_logprobs: 0,
max_tokens: 123,
max_completion_tokens: 123,
n: 1,
presence_penalty: 0,
response_format: {
json_schema: {name: '<string>', description: '<string>', schema: {}, strict: true}
},
seed: 0,
stop: [],
stream: false,
stream_options: {include_usage: true, continuous_usage_stats: false},
temperature: 123,
top_p: 123,
tools: [
{
function: {name: '<string>', description: '<string>', parameters: {}},
type: 'function'
}
],
tool_choice: 'none',
include_reasoning: true,
parallel_tool_calls: true,
user: '<string>',
use_beam_search: false,
top_k: 123,
min_p: 123,
repetition_penalty: 123,
length_penalty: 1,
stop_token_ids: [],
include_stop_str_in_output: false,
ignore_eos: false,
min_tokens: 0,
skip_special_tokens: true,
spaces_between_special_tokens: true,
truncate_prompt_tokens: 4611686018427388000,
prompt_logprobs: 123,
allowed_token_ids: [123],
bad_words: ['<string>'],
echo: false,
add_generation_prompt: true,
continue_final_message: false,
add_special_tokens: false,
documents: [{}],
chat_template: '<string>',
chat_template_kwargs: {},
mm_processor_kwargs: {},
structured_outputs: {
json: '<string>',
regex: '<string>',
choice: ['<string>'],
grammar: '<string>',
json_object: true,
disable_fallback: false,
disable_any_whitespace: false,
disable_additional_properties: false,
whitespace_pattern: '<string>',
structural_tag: '<string>',
_backend: '<string>',
_backend_was_auto: false
},
priority: 0,
request_id: '<string>',
return_tokens_as_token_ids: true,
return_token_ids: true,
cache_salt: '<string>',
kv_transfer_params: {},
vllm_xargs: {},
repetition_detection: {max_pattern_size: 0, min_pattern_size: 0, min_count: 0}
})
};
fetch('https://api.example.com/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.example.com/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([
'messages' => [
[
'content' => '<string>',
'role' => '<string>',
'name' => '<string>'
]
],
'model' => '<string>',
'frequency_penalty' => 0,
'logit_bias' => [
],
'logprobs' => false,
'top_logprobs' => 0,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'n' => 1,
'presence_penalty' => 0,
'response_format' => [
'json_schema' => [
'name' => '<string>',
'description' => '<string>',
'schema' => [
],
'strict' => true
]
],
'seed' => 0,
'stop' => [
],
'stream' => false,
'stream_options' => [
'include_usage' => true,
'continuous_usage_stats' => false
],
'temperature' => 123,
'top_p' => 123,
'tools' => [
[
'function' => [
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
],
'type' => 'function'
]
],
'tool_choice' => 'none',
'include_reasoning' => true,
'parallel_tool_calls' => true,
'user' => '<string>',
'use_beam_search' => false,
'top_k' => 123,
'min_p' => 123,
'repetition_penalty' => 123,
'length_penalty' => 1,
'stop_token_ids' => [
],
'include_stop_str_in_output' => false,
'ignore_eos' => false,
'min_tokens' => 0,
'skip_special_tokens' => true,
'spaces_between_special_tokens' => true,
'truncate_prompt_tokens' => 4611686018427388000,
'prompt_logprobs' => 123,
'allowed_token_ids' => [
123
],
'bad_words' => [
'<string>'
],
'echo' => false,
'add_generation_prompt' => true,
'continue_final_message' => false,
'add_special_tokens' => false,
'documents' => [
[
]
],
'chat_template' => '<string>',
'chat_template_kwargs' => [
],
'mm_processor_kwargs' => [
],
'structured_outputs' => [
'json' => '<string>',
'regex' => '<string>',
'choice' => [
'<string>'
],
'grammar' => '<string>',
'json_object' => true,
'disable_fallback' => false,
'disable_any_whitespace' => false,
'disable_additional_properties' => false,
'whitespace_pattern' => '<string>',
'structural_tag' => '<string>',
'_backend' => '<string>',
'_backend_was_auto' => false
],
'priority' => 0,
'request_id' => '<string>',
'return_tokens_as_token_ids' => true,
'return_token_ids' => true,
'cache_salt' => '<string>',
'kv_transfer_params' => [
],
'vllm_xargs' => [
],
'repetition_detection' => [
'max_pattern_size' => 0,
'min_pattern_size' => 0,
'min_count' => 0
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.example.com/v1/chat/completions/"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 0,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n },\n \"type\": \"function\"\n }\n ],\n \"tool_choice\": \"none\",\n \"include_reasoning\": true,\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"length_penalty\": 1,\n \"stop_token_ids\": [],\n \"include_stop_str_in_output\": false,\n \"ignore_eos\": false,\n \"min_tokens\": 0,\n \"skip_special_tokens\": true,\n \"spaces_between_special_tokens\": true,\n \"truncate_prompt_tokens\": 4611686018427388000,\n \"prompt_logprobs\": 123,\n \"allowed_token_ids\": [\n 123\n ],\n \"bad_words\": [\n \"<string>\"\n ],\n \"echo\": false,\n \"add_generation_prompt\": true,\n \"continue_final_message\": false,\n \"add_special_tokens\": false,\n \"documents\": [\n {}\n ],\n \"chat_template\": \"<string>\",\n \"chat_template_kwargs\": {},\n \"mm_processor_kwargs\": {},\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_fallback\": false,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\",\n \"_backend\": \"<string>\",\n \"_backend_was_auto\": false\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"kv_transfer_params\": {},\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.example.com/v1/chat/completions/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 0,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n },\n \"type\": \"function\"\n }\n ],\n \"tool_choice\": \"none\",\n \"include_reasoning\": true,\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"length_penalty\": 1,\n \"stop_token_ids\": [],\n \"include_stop_str_in_output\": false,\n \"ignore_eos\": false,\n \"min_tokens\": 0,\n \"skip_special_tokens\": true,\n \"spaces_between_special_tokens\": true,\n \"truncate_prompt_tokens\": 4611686018427388000,\n \"prompt_logprobs\": 123,\n \"allowed_token_ids\": [\n 123\n ],\n \"bad_words\": [\n \"<string>\"\n ],\n \"echo\": false,\n \"add_generation_prompt\": true,\n \"continue_final_message\": false,\n \"add_special_tokens\": false,\n \"documents\": [\n {}\n ],\n \"chat_template\": \"<string>\",\n \"chat_template_kwargs\": {},\n \"mm_processor_kwargs\": {},\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_fallback\": false,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\",\n \"_backend\": \"<string>\",\n \"_backend_was_auto\": false\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"kv_transfer_params\": {},\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/chat/completions/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 0,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n },\n \"type\": \"function\"\n }\n ],\n \"tool_choice\": \"none\",\n \"include_reasoning\": true,\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"length_penalty\": 1,\n \"stop_token_ids\": [],\n \"include_stop_str_in_output\": false,\n \"ignore_eos\": false,\n \"min_tokens\": 0,\n \"skip_special_tokens\": true,\n \"spaces_between_special_tokens\": true,\n \"truncate_prompt_tokens\": 4611686018427388000,\n \"prompt_logprobs\": 123,\n \"allowed_token_ids\": [\n 123\n ],\n \"bad_words\": [\n \"<string>\"\n ],\n \"echo\": false,\n \"add_generation_prompt\": true,\n \"continue_final_message\": false,\n \"add_special_tokens\": false,\n \"documents\": [\n {}\n ],\n \"chat_template\": \"<string>\",\n \"chat_template_kwargs\": {},\n \"mm_processor_kwargs\": {},\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_fallback\": false,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\",\n \"_backend\": \"<string>\",\n \"_backend_was_auto\": false\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"kv_transfer_params\": {},\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>",
"refusal": "<string>",
"annotations": {
"type": "<string>",
"url_citation": {
"end_index": 123,
"start_index": 123,
"title": "<string>",
"url": "<string>"
}
},
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": 123,
"transcript": "<string>"
},
"function_call": {
"name": "<string>",
"arguments": "<string>"
},
"tool_calls": [
{
"function": {
"name": "<string>",
"arguments": "<string>"
},
"id": "<string>",
"type": "function"
}
],
"reasoning": "<string>"
},
"logprobs": {
"content": [
{
"token": "<string>",
"logprob": -9999,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": -9999,
"bytes": [
123
]
}
]
}
]
},
"finish_reason": "stop",
"stop_reason": 123,
"token_ids": [
123
]
}
],
"usage": {
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 123
}
},
"id": "<string>",
"object": "chat.completion",
"created": 123,
"system_fingerprint": "<string>",
"prompt_logprobs": [
{}
],
"prompt_token_ids": [
123
],
"kv_transfer_params": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Create Chat Completion
Create a new chat completion.
curl --request POST \
--url https://api.example.com/v1/chat/completions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": false,
"top_logprobs": 0,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": {
"json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
}
},
"seed": 0,
"stop": [],
"stream": false,
"stream_options": {
"include_usage": true,
"continuous_usage_stats": false
},
"temperature": 123,
"top_p": 123,
"tools": [
{
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
},
"type": "function"
}
],
"tool_choice": "none",
"include_reasoning": true,
"parallel_tool_calls": true,
"user": "<string>",
"use_beam_search": false,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"length_penalty": 1,
"stop_token_ids": [],
"include_stop_str_in_output": false,
"ignore_eos": false,
"min_tokens": 0,
"skip_special_tokens": true,
"spaces_between_special_tokens": true,
"truncate_prompt_tokens": 4611686018427388000,
"prompt_logprobs": 123,
"allowed_token_ids": [
123
],
"bad_words": [
"<string>"
],
"echo": false,
"add_generation_prompt": true,
"continue_final_message": false,
"add_special_tokens": false,
"documents": [
{}
],
"chat_template": "<string>",
"chat_template_kwargs": {},
"mm_processor_kwargs": {},
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": [
"<string>"
],
"grammar": "<string>",
"json_object": true,
"disable_fallback": false,
"disable_any_whitespace": false,
"disable_additional_properties": false,
"whitespace_pattern": "<string>",
"structural_tag": "<string>",
"_backend": "<string>",
"_backend_was_auto": false
},
"priority": 0,
"request_id": "<string>",
"return_tokens_as_token_ids": true,
"return_token_ids": true,
"cache_salt": "<string>",
"kv_transfer_params": {},
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
}
}
'import requests
url = "https://api.example.com/v1/chat/completions/"
payload = {
"messages": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": False,
"top_logprobs": 0,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": { "json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": True
} },
"seed": 0,
"stop": [],
"stream": False,
"stream_options": {
"include_usage": True,
"continuous_usage_stats": False
},
"temperature": 123,
"top_p": 123,
"tools": [
{
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
},
"type": "function"
}
],
"tool_choice": "none",
"include_reasoning": True,
"parallel_tool_calls": True,
"user": "<string>",
"use_beam_search": False,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"length_penalty": 1,
"stop_token_ids": [],
"include_stop_str_in_output": False,
"ignore_eos": False,
"min_tokens": 0,
"skip_special_tokens": True,
"spaces_between_special_tokens": True,
"truncate_prompt_tokens": 4611686018427388000,
"prompt_logprobs": 123,
"allowed_token_ids": [123],
"bad_words": ["<string>"],
"echo": False,
"add_generation_prompt": True,
"continue_final_message": False,
"add_special_tokens": False,
"documents": [{}],
"chat_template": "<string>",
"chat_template_kwargs": {},
"mm_processor_kwargs": {},
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": ["<string>"],
"grammar": "<string>",
"json_object": True,
"disable_fallback": False,
"disable_any_whitespace": False,
"disable_additional_properties": False,
"whitespace_pattern": "<string>",
"structural_tag": "<string>",
"_backend": "<string>",
"_backend_was_auto": False
},
"priority": 0,
"request_id": "<string>",
"return_tokens_as_token_ids": True,
"return_token_ids": True,
"cache_salt": "<string>",
"kv_transfer_params": {},
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{content: '<string>', role: '<string>', name: '<string>'}],
model: '<string>',
frequency_penalty: 0,
logit_bias: {},
logprobs: false,
top_logprobs: 0,
max_tokens: 123,
max_completion_tokens: 123,
n: 1,
presence_penalty: 0,
response_format: {
json_schema: {name: '<string>', description: '<string>', schema: {}, strict: true}
},
seed: 0,
stop: [],
stream: false,
stream_options: {include_usage: true, continuous_usage_stats: false},
temperature: 123,
top_p: 123,
tools: [
{
function: {name: '<string>', description: '<string>', parameters: {}},
type: 'function'
}
],
tool_choice: 'none',
include_reasoning: true,
parallel_tool_calls: true,
user: '<string>',
use_beam_search: false,
top_k: 123,
min_p: 123,
repetition_penalty: 123,
length_penalty: 1,
stop_token_ids: [],
include_stop_str_in_output: false,
ignore_eos: false,
min_tokens: 0,
skip_special_tokens: true,
spaces_between_special_tokens: true,
truncate_prompt_tokens: 4611686018427388000,
prompt_logprobs: 123,
allowed_token_ids: [123],
bad_words: ['<string>'],
echo: false,
add_generation_prompt: true,
continue_final_message: false,
add_special_tokens: false,
documents: [{}],
chat_template: '<string>',
chat_template_kwargs: {},
mm_processor_kwargs: {},
structured_outputs: {
json: '<string>',
regex: '<string>',
choice: ['<string>'],
grammar: '<string>',
json_object: true,
disable_fallback: false,
disable_any_whitespace: false,
disable_additional_properties: false,
whitespace_pattern: '<string>',
structural_tag: '<string>',
_backend: '<string>',
_backend_was_auto: false
},
priority: 0,
request_id: '<string>',
return_tokens_as_token_ids: true,
return_token_ids: true,
cache_salt: '<string>',
kv_transfer_params: {},
vllm_xargs: {},
repetition_detection: {max_pattern_size: 0, min_pattern_size: 0, min_count: 0}
})
};
fetch('https://api.example.com/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.example.com/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([
'messages' => [
[
'content' => '<string>',
'role' => '<string>',
'name' => '<string>'
]
],
'model' => '<string>',
'frequency_penalty' => 0,
'logit_bias' => [
],
'logprobs' => false,
'top_logprobs' => 0,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'n' => 1,
'presence_penalty' => 0,
'response_format' => [
'json_schema' => [
'name' => '<string>',
'description' => '<string>',
'schema' => [
],
'strict' => true
]
],
'seed' => 0,
'stop' => [
],
'stream' => false,
'stream_options' => [
'include_usage' => true,
'continuous_usage_stats' => false
],
'temperature' => 123,
'top_p' => 123,
'tools' => [
[
'function' => [
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
],
'type' => 'function'
]
],
'tool_choice' => 'none',
'include_reasoning' => true,
'parallel_tool_calls' => true,
'user' => '<string>',
'use_beam_search' => false,
'top_k' => 123,
'min_p' => 123,
'repetition_penalty' => 123,
'length_penalty' => 1,
'stop_token_ids' => [
],
'include_stop_str_in_output' => false,
'ignore_eos' => false,
'min_tokens' => 0,
'skip_special_tokens' => true,
'spaces_between_special_tokens' => true,
'truncate_prompt_tokens' => 4611686018427388000,
'prompt_logprobs' => 123,
'allowed_token_ids' => [
123
],
'bad_words' => [
'<string>'
],
'echo' => false,
'add_generation_prompt' => true,
'continue_final_message' => false,
'add_special_tokens' => false,
'documents' => [
[
]
],
'chat_template' => '<string>',
'chat_template_kwargs' => [
],
'mm_processor_kwargs' => [
],
'structured_outputs' => [
'json' => '<string>',
'regex' => '<string>',
'choice' => [
'<string>'
],
'grammar' => '<string>',
'json_object' => true,
'disable_fallback' => false,
'disable_any_whitespace' => false,
'disable_additional_properties' => false,
'whitespace_pattern' => '<string>',
'structural_tag' => '<string>',
'_backend' => '<string>',
'_backend_was_auto' => false
],
'priority' => 0,
'request_id' => '<string>',
'return_tokens_as_token_ids' => true,
'return_token_ids' => true,
'cache_salt' => '<string>',
'kv_transfer_params' => [
],
'vllm_xargs' => [
],
'repetition_detection' => [
'max_pattern_size' => 0,
'min_pattern_size' => 0,
'min_count' => 0
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.example.com/v1/chat/completions/"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 0,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n },\n \"type\": \"function\"\n }\n ],\n \"tool_choice\": \"none\",\n \"include_reasoning\": true,\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"length_penalty\": 1,\n \"stop_token_ids\": [],\n \"include_stop_str_in_output\": false,\n \"ignore_eos\": false,\n \"min_tokens\": 0,\n \"skip_special_tokens\": true,\n \"spaces_between_special_tokens\": true,\n \"truncate_prompt_tokens\": 4611686018427388000,\n \"prompt_logprobs\": 123,\n \"allowed_token_ids\": [\n 123\n ],\n \"bad_words\": [\n \"<string>\"\n ],\n \"echo\": false,\n \"add_generation_prompt\": true,\n \"continue_final_message\": false,\n \"add_special_tokens\": false,\n \"documents\": [\n {}\n ],\n \"chat_template\": \"<string>\",\n \"chat_template_kwargs\": {},\n \"mm_processor_kwargs\": {},\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_fallback\": false,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\",\n \"_backend\": \"<string>\",\n \"_backend_was_auto\": false\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"kv_transfer_params\": {},\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.example.com/v1/chat/completions/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 0,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n },\n \"type\": \"function\"\n }\n ],\n \"tool_choice\": \"none\",\n \"include_reasoning\": true,\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"length_penalty\": 1,\n \"stop_token_ids\": [],\n \"include_stop_str_in_output\": false,\n \"ignore_eos\": false,\n \"min_tokens\": 0,\n \"skip_special_tokens\": true,\n \"spaces_between_special_tokens\": true,\n \"truncate_prompt_tokens\": 4611686018427388000,\n \"prompt_logprobs\": 123,\n \"allowed_token_ids\": [\n 123\n ],\n \"bad_words\": [\n \"<string>\"\n ],\n \"echo\": false,\n \"add_generation_prompt\": true,\n \"continue_final_message\": false,\n \"add_special_tokens\": false,\n \"documents\": [\n {}\n ],\n \"chat_template\": \"<string>\",\n \"chat_template_kwargs\": {},\n \"mm_processor_kwargs\": {},\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_fallback\": false,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\",\n \"_backend\": \"<string>\",\n \"_backend_was_auto\": false\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"kv_transfer_params\": {},\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/chat/completions/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 0,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n },\n \"type\": \"function\"\n }\n ],\n \"tool_choice\": \"none\",\n \"include_reasoning\": true,\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"length_penalty\": 1,\n \"stop_token_ids\": [],\n \"include_stop_str_in_output\": false,\n \"ignore_eos\": false,\n \"min_tokens\": 0,\n \"skip_special_tokens\": true,\n \"spaces_between_special_tokens\": true,\n \"truncate_prompt_tokens\": 4611686018427388000,\n \"prompt_logprobs\": 123,\n \"allowed_token_ids\": [\n 123\n ],\n \"bad_words\": [\n \"<string>\"\n ],\n \"echo\": false,\n \"add_generation_prompt\": true,\n \"continue_final_message\": false,\n \"add_special_tokens\": false,\n \"documents\": [\n {}\n ],\n \"chat_template\": \"<string>\",\n \"chat_template_kwargs\": {},\n \"mm_processor_kwargs\": {},\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_fallback\": false,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\",\n \"_backend\": \"<string>\",\n \"_backend_was_auto\": false\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"kv_transfer_params\": {},\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>",
"refusal": "<string>",
"annotations": {
"type": "<string>",
"url_citation": {
"end_index": 123,
"start_index": 123,
"title": "<string>",
"url": "<string>"
}
},
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": 123,
"transcript": "<string>"
},
"function_call": {
"name": "<string>",
"arguments": "<string>"
},
"tool_calls": [
{
"function": {
"name": "<string>",
"arguments": "<string>"
},
"id": "<string>",
"type": "function"
}
],
"reasoning": "<string>"
},
"logprobs": {
"content": [
{
"token": "<string>",
"logprob": -9999,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": -9999,
"bytes": [
123
]
}
]
}
]
},
"finish_reason": "stop",
"stop_reason": 123,
"token_ids": [
123
]
}
],
"usage": {
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 123
}
},
"id": "<string>",
"object": "chat.completion",
"created": 123,
"system_fingerprint": "<string>",
"prompt_logprobs": [
{}
],
"prompt_token_ids": [
123
],
"kv_transfer_params": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Developer-provided instructions that the model should follow, regardless of
messages sent by the user. With o1 models and newer, developer messages
replace the previous system messages.
- ChatCompletionDeveloperMessageParam
- ChatCompletionSystemMessageParam
- ChatCompletionUserMessageParam
- ChatCompletionAssistantMessageParam
- ChatCompletionToolMessageParam
- ChatCompletionFunctionMessageParam
- CustomChatCompletionMessageParam
- Message
Show child attributes
Show child attributes
Show child attributes
Show child attributes
- ResponseFormat
- StructuralTagResponseFormat
- LegacyStructuralTagResponseFormat
Show child attributes
Show child attributes
-9223372036854776000 <= x <= 9223372036854776000Show child attributes
Show child attributes
Show child attributes
Show child attributes
"none"low, medium, high -1 <= x <= 9223372036854776000If true, the new message will be prepended with the last message if they belong to the same role.
If true, the generation prompt will be added to the chat template. This is a parameter used by chat template in tokenizer config of the model.
If this is set, the chat will be formatted so that the final message in the chat is open-ended, without any EOS tokens. The model will continue this message rather than starting a new one. This allows you to "prefill" part of the model's response for it. Cannot be used at the same time as add_generation_prompt.
If true, special tokens (e.g. BOS) will be added to the prompt on top of what is added by the chat template. For most models, the chat template takes care of adding the special tokens so this should be set to false (as is the default).
A list of dicts representing documents that will be accessible to the model if it is performing RAG (retrieval-augmented generation). If the template does not support RAG, this argument will have no effect. We recommend that each document should be a dict containing "title" and "text" keys.
Show child attributes
Show child attributes
A Jinja template to use for this conversion. As of transformers v4.44, default chat template is no longer allowed, so you must provide a chat template if the tokenizer does not define one.
Additional keyword args to pass to the template renderer. Will be accessible by the chat template.
Additional kwargs to pass to the HF processor.
Additional kwargs for structured outputs
Show child attributes
Show child attributes
The priority of the request (lower means earlier handling; default: 0). Any priority other than 0 will raise an error if the served model does not use priority scheduling.
The request_id related to this request. If the caller does not set it, a random_uuid will be generated. This id is used through out the inference process and return in response.
If specified with 'logprobs', tokens are represented as strings of the form 'token_id:{token_id}' so that tokens that are not JSON-encodable can be identified.
If specified, the result will include token IDs alongside the generated text. In streaming mode, prompt_token_ids is included only in the first chunk, and token_ids contains the delta tokens for each chunk. This is useful for debugging or when you need to map generated text back to input tokens.
If specified, the prefix cache will be salted with the provided string to prevent an attacker to guess prompts in multi-user environments. The salt should be random, protected from access by 3rd parties, and long enough to be unpredictable (e.g., 43 characters base64-encoded, corresponding to 256 bit).
KVTransfer parameters used for disaggregated serving.
Additional request parameters with (list of) string or numeric values, used by custom extensions.
Show child attributes
Show child attributes
Parameters for detecting repetitive N-gram patterns in output tokens. If such repetition is detected, generation will be ended early. LLMs can sometimes generate repetitive, unhelpful token patterns, stopping only when they hit the maximum output length (e.g. 'abcdabcdabcd...' or '\emoji \emoji \emoji ...'). This feature can detect such behavior and terminate early, saving time and tokens.
Show child attributes
Show child attributes
Response
Successful Response
Show child attributes
Show child attributes
Show child attributes
Show child attributes
"chat.completion"auto, default, flex, scale, priority Show child attributes
Show child attributes
KVTransfer parameters.
Was this page helpful?