Create chat completion
curl --request POST \
--url https://api.cogito.decart.ai/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": true,
"n": 123,
"logprobs": true,
"include_routing_matrix": true,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"tools": [
{}
],
"tool_choice": {},
"response_format": {},
"stop": [
"<string>"
],
"frequency_penalty": 123,
"presence_penalty": 123,
"reasoning_effort": "<string>",
"chat_template_kwargs": {}
}
'import requests
url = "https://api.cogito.decart.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": True,
"n": 123,
"logprobs": True,
"include_routing_matrix": True,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"tools": [{}],
"tool_choice": {},
"response_format": {},
"stop": ["<string>"],
"frequency_penalty": 123,
"presence_penalty": 123,
"reasoning_effort": "<string>",
"chat_template_kwargs": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
stream: true,
n: 123,
logprobs: true,
include_routing_matrix: true,
sampling_mask: '<string>',
temperature: 123,
top_p: 123,
max_tokens: 123,
max_completion_tokens: 123,
tools: [{}],
tool_choice: {},
response_format: {},
stop: ['<string>'],
frequency_penalty: 123,
presence_penalty: 123,
reasoning_effort: '<string>',
chat_template_kwargs: {}
})
};
fetch('https://api.cogito.decart.ai/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.cogito.decart.ai/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' => [
[
]
],
'stream' => true,
'n' => 123,
'logprobs' => true,
'include_routing_matrix' => true,
'sampling_mask' => '<string>',
'temperature' => 123,
'top_p' => 123,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'tools' => [
[
]
],
'tool_choice' => [
],
'response_format' => [
],
'stop' => [
'<string>'
],
'frequency_penalty' => 123,
'presence_penalty' => 123,
'reasoning_effort' => '<string>',
'chat_template_kwargs' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.cogito.decart.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"n\": 123,\n \"logprobs\": true,\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"reasoning_effort\": \"<string>\",\n \"chat_template_kwargs\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.cogito.decart.ai/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"n\": 123,\n \"logprobs\": true,\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"reasoning_effort\": \"<string>\",\n \"chat_template_kwargs\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cogito.decart.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"n\": 123,\n \"logprobs\": true,\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"reasoning_effort\": \"<string>\",\n \"chat_template_kwargs\": {}\n}"
response = http.request(request)
puts response.read_bodyChat
Create chat completion
POST /v1/chat/completions
POST
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
--url https://api.cogito.decart.ai/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": true,
"n": 123,
"logprobs": true,
"include_routing_matrix": true,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"tools": [
{}
],
"tool_choice": {},
"response_format": {},
"stop": [
"<string>"
],
"frequency_penalty": 123,
"presence_penalty": 123,
"reasoning_effort": "<string>",
"chat_template_kwargs": {}
}
'import requests
url = "https://api.cogito.decart.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": True,
"n": 123,
"logprobs": True,
"include_routing_matrix": True,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"tools": [{}],
"tool_choice": {},
"response_format": {},
"stop": ["<string>"],
"frequency_penalty": 123,
"presence_penalty": 123,
"reasoning_effort": "<string>",
"chat_template_kwargs": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
stream: true,
n: 123,
logprobs: true,
include_routing_matrix: true,
sampling_mask: '<string>',
temperature: 123,
top_p: 123,
max_tokens: 123,
max_completion_tokens: 123,
tools: [{}],
tool_choice: {},
response_format: {},
stop: ['<string>'],
frequency_penalty: 123,
presence_penalty: 123,
reasoning_effort: '<string>',
chat_template_kwargs: {}
})
};
fetch('https://api.cogito.decart.ai/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.cogito.decart.ai/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' => [
[
]
],
'stream' => true,
'n' => 123,
'logprobs' => true,
'include_routing_matrix' => true,
'sampling_mask' => '<string>',
'temperature' => 123,
'top_p' => 123,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'tools' => [
[
]
],
'tool_choice' => [
],
'response_format' => [
],
'stop' => [
'<string>'
],
'frequency_penalty' => 123,
'presence_penalty' => 123,
'reasoning_effort' => '<string>',
'chat_template_kwargs' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.cogito.decart.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"n\": 123,\n \"logprobs\": true,\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"reasoning_effort\": \"<string>\",\n \"chat_template_kwargs\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.cogito.decart.ai/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"n\": 123,\n \"logprobs\": true,\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"reasoning_effort\": \"<string>\",\n \"chat_template_kwargs\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cogito.decart.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"n\": 123,\n \"logprobs\": true,\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"reasoning_effort\": \"<string>\",\n \"chat_template_kwargs\": {}\n}"
response = http.request(request)
puts response.read_bodyOpenAI-compatible chat completions endpoint. Streaming and non-streaming.
Request body
array
required
Conversation history. Each entry is
{ role: "system" | "user" | "assistant" | "tool", content: string }.boolean
default:"false"
When
true, responses are streamed as Server-Sent Events. For routing
matrices, set stream: false. See the streaming guide.integer
default:"1"
Number of choices to generate. For routing matrices, set
n: 1.boolean
default:"false"
When
true, return generated-token logprobs in
choices[].logprobs.content. Required for routing matrices.boolean
default:"false"
On supported MoE rollout models, add the selected expert indices for each
generated token to
choices[].logprobs.content[].routing_matrix. Requires
logprobs: true, stream: false, and n: 1.string
On rollout-enabled models, return post-filter sampling metadata on every
generated token. Accepted values are
count, non_zero_list, and
non_zero_buffer. Requires logprobs: true. Every mode adds
sampling_logprob and sampling_mask_count to
choices[].logprobs.content[]; list mode adds the complete kept set as
integer token IDs, while buffer mode adds the same IDs as base64
little-endian uint32 values. The field is compatible with
include_routing_matrix.number
default:"1"
Sampling temperature,
0 to 2. Lower → more deterministic.number
default:"1"
Nucleus sampling. Use either
temperature or top_p, not both.integer
Maximum output tokens. Capped per tier — see pricing.
Clamped to the model’s
max_output_length (visible on /v1/models).integer
Same semantics as
max_tokens; OpenAI’s canonical field for o1/o3
reasoning models. Either field is accepted; if both are sent,
max_completion_tokens wins. Clamped to the model’s
max_output_length.array
Available tools the model may call. See function calling.
string | object
default:"auto"
"auto" (default), "none", or { type: "function", function: { name: ... } } to force.object
{ type: "json_object" } or { type: "json_schema", json_schema: {...} }. See structured outputs.string | string[]
Up to 4 stop sequences.
number
default:"0"
-2.0 to 2.0. Penalize tokens by their frequency in the response so far.number
default:"0"
-2.0 to 2.0. Penalize tokens that have appeared at all.string
Reasoning effort hint for models that emit a chain of thought —
accepted as the standard OpenAI top-level field. For DeepSeek-V4
the gateway mirrors this value into
chat_template_kwargs.reasoning_effort and strips the top-level
field before forwarding, because DeepSeek-V4’s chat template only
consumes the engine-specific form. Without this mirror, top-level
reasoning_effort is silently a no-op on V4 (it’s also a
SamplingParams interference source when the value is outside
OpenAI’s enum). The OpenRouter-style alias "xhigh" is mapped to
DeepSeek’s "max" (“Think Max” mode). DeepSeek-V4 documents
"high" and "max"; other OpenAI tiers
(minimal | low | medium) are forwarded literally but fall back to
the encoder’s default branch on this build — i.e. they don’t 400
but may produce reasoning depth indistinguishable from sending no
hint. Disable thinking entirely with
chat_template_kwargs.enable_thinking: false. If you set
chat_template_kwargs.reasoning_effort explicitly, the gateway
honors your value and leaves the top-level field alone.object
Engine-specific chat-template knobs forwarded verbatim to the
upstream. On DeepSeek-V4:
{ enable_thinking: false } disables
reasoning and routes output directly to content;
{ drop_thinking: true } drops prior assistant reasoning_content
from the encoded prompt. Cogito defaults drop_thinking to false
for reasoning-capable models so multi-turn requests preserve prior
reasoning traces unless you explicitly opt out;
{ reasoning_effort: "high" | "max" } selects the model’s
Think-High vs Think-Max mode. The gateway force-injects
enable_thinking: false when response_format is set (so JSON-mode
and structured outputs land in content, not reasoning_content);
any caller-supplied value here always wins.Response (non-streaming)
{
"id": "req_...",
"object": "chat.completion",
"created": 1714521600,
"model": "gpt-oss-120b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 32,
"completion_tokens": 71,
"total_tokens": 103,
"prompt_tokens_details": { "cached_tokens": 0 },
"completion_tokens_details": { "reasoning_tokens": 0 }
}
}
Response (streaming)
Content-Type: text/event-stream. Each event is
data: <chat.completion.chunk JSON>. Stream ends with data: [DONE]. See the
streaming guide.
When sampling_mask is set, sampling metadata stays on the same token
logprob entry in both non-streaming responses and streamed token chunks.
Provider-private transport fields are never returned.
Headers on every response
x-request-id— opaque ID. Log it. We trace it through every layer.x-tokens-used— billed total for this request (omitted on errors that didn’t consume tokens).