Create completion
curl --request POST \
--url https://api.cogito.decart.ai/v1/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": [
"<string>"
],
"stream": true,
"max_tokens": 123,
"n": 123,
"logprobs": {},
"echo": {},
"echo_last": {},
"include_routing_matrix": true,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"stop": [
"<string>"
],
"frequency_penalty": 123,
"presence_penalty": 123,
"ignore_eos": true
}
'import requests
url = "https://api.cogito.decart.ai/v1/completions"
payload = {
"model": "<string>",
"prompt": ["<string>"],
"stream": True,
"max_tokens": 123,
"n": 123,
"logprobs": {},
"echo": {},
"echo_last": {},
"include_routing_matrix": True,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"stop": ["<string>"],
"frequency_penalty": 123,
"presence_penalty": 123,
"ignore_eos": True
}
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>',
prompt: ['<string>'],
stream: true,
max_tokens: 123,
n: 123,
logprobs: {},
echo: {},
echo_last: {},
include_routing_matrix: true,
sampling_mask: '<string>',
temperature: 123,
top_p: 123,
stop: ['<string>'],
frequency_penalty: 123,
presence_penalty: 123,
ignore_eos: true
})
};
fetch('https://api.cogito.decart.ai/v1/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/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>',
'prompt' => [
'<string>'
],
'stream' => true,
'max_tokens' => 123,
'n' => 123,
'logprobs' => [
],
'echo' => [
],
'echo_last' => [
],
'include_routing_matrix' => true,
'sampling_mask' => '<string>',
'temperature' => 123,
'top_p' => 123,
'stop' => [
'<string>'
],
'frequency_penalty' => 123,
'presence_penalty' => 123,
'ignore_eos' => true
]),
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/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": [\n \"<string>\"\n ],\n \"stream\": true,\n \"max_tokens\": 123,\n \"n\": 123,\n \"logprobs\": {},\n \"echo\": {},\n \"echo_last\": {},\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"ignore_eos\": true\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/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": [\n \"<string>\"\n ],\n \"stream\": true,\n \"max_tokens\": 123,\n \"n\": 123,\n \"logprobs\": {},\n \"echo\": {},\n \"echo_last\": {},\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"ignore_eos\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cogito.decart.ai/v1/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 \"prompt\": [\n \"<string>\"\n ],\n \"stream\": true,\n \"max_tokens\": 123,\n \"n\": 123,\n \"logprobs\": {},\n \"echo\": {},\n \"echo_last\": {},\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"ignore_eos\": true\n}"
response = http.request(request)
puts response.read_bodyChat
Create completion
POST /v1/completions
POST
/
v1
/
completions
Create completion
curl --request POST \
--url https://api.cogito.decart.ai/v1/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": [
"<string>"
],
"stream": true,
"max_tokens": 123,
"n": 123,
"logprobs": {},
"echo": {},
"echo_last": {},
"include_routing_matrix": true,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"stop": [
"<string>"
],
"frequency_penalty": 123,
"presence_penalty": 123,
"ignore_eos": true
}
'import requests
url = "https://api.cogito.decart.ai/v1/completions"
payload = {
"model": "<string>",
"prompt": ["<string>"],
"stream": True,
"max_tokens": 123,
"n": 123,
"logprobs": {},
"echo": {},
"echo_last": {},
"include_routing_matrix": True,
"sampling_mask": "<string>",
"temperature": 123,
"top_p": 123,
"stop": ["<string>"],
"frequency_penalty": 123,
"presence_penalty": 123,
"ignore_eos": True
}
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>',
prompt: ['<string>'],
stream: true,
max_tokens: 123,
n: 123,
logprobs: {},
echo: {},
echo_last: {},
include_routing_matrix: true,
sampling_mask: '<string>',
temperature: 123,
top_p: 123,
stop: ['<string>'],
frequency_penalty: 123,
presence_penalty: 123,
ignore_eos: true
})
};
fetch('https://api.cogito.decart.ai/v1/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/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>',
'prompt' => [
'<string>'
],
'stream' => true,
'max_tokens' => 123,
'n' => 123,
'logprobs' => [
],
'echo' => [
],
'echo_last' => [
],
'include_routing_matrix' => true,
'sampling_mask' => '<string>',
'temperature' => 123,
'top_p' => 123,
'stop' => [
'<string>'
],
'frequency_penalty' => 123,
'presence_penalty' => 123,
'ignore_eos' => true
]),
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/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": [\n \"<string>\"\n ],\n \"stream\": true,\n \"max_tokens\": 123,\n \"n\": 123,\n \"logprobs\": {},\n \"echo\": {},\n \"echo_last\": {},\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"ignore_eos\": true\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/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": [\n \"<string>\"\n ],\n \"stream\": true,\n \"max_tokens\": 123,\n \"n\": 123,\n \"logprobs\": {},\n \"echo\": {},\n \"echo_last\": {},\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"ignore_eos\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cogito.decart.ai/v1/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 \"prompt\": [\n \"<string>\"\n ],\n \"stream\": true,\n \"max_tokens\": 123,\n \"n\": 123,\n \"logprobs\": {},\n \"echo\": {},\n \"echo_last\": {},\n \"include_routing_matrix\": true,\n \"sampling_mask\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"ignore_eos\": true\n}"
response = http.request(request)
puts response.read_bodyLegacy OpenAI-compatible text completions endpoint for prompt-based clients and
benchmark harnesses. Use chat completions for
new applications.
This route is available for live inference models. Placeholder catalog rows are
rejected with
model_not_found instead of returning a synthetic completion.
Request body
string | string[] | integer[] | integer[][]
required
Prompt text or token ids to complete. For prompt replay, pass one string or
one non-empty token-id list.
boolean
default:"false"
When
true, responses are streamed as Server-Sent Events and end with
data: [DONE].integer
Maximum output tokens. Clamped to the model’s
max_output_length.integer
default:"1"
Number of completions to generate.
boolean | integer | null
Request a number of most likely tokens at each position from
0 through
5. The boolean value true is accepted for token-aligned metadata requests
using sampling_mask or include_routing_matrix. Completion logprobs use the
legacy OpenAI arrays: tokens,
token_logprobs, top_logprobs, and text_offset. Routing matrices require
true or a numeric value.boolean | null
default:"false"
On supported rollout models,
true prepends the full prompt to
choices[].text. Use stream: false and n: 1 for prompt replay.integer | null
On supported rollout models, prepends the last N authoritative prompt
tokens. It must be a non-negative safe integer.
0 selects zero prompt
tokens; a value longer than the prompt selects the full prompt. A non-null
echo_last overrides echo, including echo_last: 0. Use stream: false
and n: 1.boolean
default:"false"
On supported MoE rollout models, add the selected expert indices for each
scored token to
choices[].logprobs.content[].routing_matrix. Requires
logprobs: true or numeric logprobs, 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; all require logprobs: true. Each
choices[].logprobs.content[] entry receives sampling_logprob and
sampling_mask_count. List mode returns the complete kept set as integer
token IDs; buffer mode returns the same IDs as base64 little-endian uint32
values. The field composes with include_routing_matrix.number
default:"1"
Sampling temperature,
0 to 2. Lower values are more deterministic.number
default:"1"
Nucleus sampling,
0 to 1. Use either temperature or top_p, not both.
0 keeps only the most likely token (greedy decoding).string | string[]
Stop sequence or 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.boolean
Engine extension used by fixed-length benchmark harnesses. When supported by
the selected upstream, the model continues until
max_tokens or another stop
condition is reached.Example
curl https://api.cogito.decart.ai/v1/completions \
-H "Authorization: Bearer $COGITO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "moonshotai/kimi-k2.6:appliedcompute",
"prompt": "Write one sentence about fast inference:",
"max_tokens": 32
}'
Response
{
"id": "cmpl_...",
"object": "text_completion",
"created": 1714521600,
"model": "moonshotai/kimi-k2.6",
"choices": [
{
"index": 0,
"text": " Fast inference keeps agent loops tight.",
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 8,
"total_tokens": 16
}
}
Prompt replay response
An active selector returns the full authoritative prompt ids separately from the generated ids:choices[].prompt_token_idscontains the full prompt, even whenecho_lastselects only a suffix or zero tokens.choices[].token_idscontains generated tokens only.choices[].textcontains the selected prompt suffix followed by generated text.
usage.prompt_tokens counts the full prompt and
usage.completion_tokens counts generated tokens; echoing text does not change
billing counts.
For a full prompt echo, choices[].text, prompt_token_ids, and the legacy
tokens array begin with the first global prompt token, whose token_logprobs
entry is null. The additive choices[].logprobs.content extension begins
with the second prompt token and continues through every generated token,
keeping each score aligned with its route.
When sampling_mask is set, the generated-token content entries also carry
the public sampling fields. Provider-private transport fields are stripped
from both non-streaming responses and streamed chunks.
Headers on every response
x-request-id— opaque ID. Log it. We trace it through every layer.