curl --request POST \
--url https://inference.api.nscale.com/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": [
1
],
"echo": false,
"frequency_penalty": 123,
"logit_bias": {},
"logprobs": 123,
"max_tokens": 16,
"n": 1,
"presence_penalty": 123,
"seed": 0,
"stop": [],
"stream": false,
"stream_options": {
"include_usage": false,
"continuous_usage_stats": false
},
"suffix": "<string>",
"temperature": 123,
"top_p": 123,
"user": "<string>",
"use_beam_search": false,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"watermarking": true,
"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,
"allowed_token_ids": [
123
],
"prompt_logprobs": 123,
"logprob_token_ids": [
123
],
"bad_words": [],
"prompt_embeds": "<string>",
"add_special_tokens": true,
"response_format": {
"json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
}
},
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": [
"<string>"
],
"grammar": "<string>",
"json_object": true,
"disable_any_whitespace": false,
"disable_additional_properties": false,
"whitespace_pattern": "<string>",
"structural_tag": "<string>"
},
"priority": 0,
"request_id": "<string>",
"session_id": "<string>",
"return_tokens_as_token_ids": true,
"return_token_ids": true,
"cache_salt": "<string>",
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
},
"thinking_token_budget": 0,
"stream_interval": 2
}
'import requests
url = "https://inference.api.nscale.com/v1/completions"
payload = {
"model": "<string>",
"prompt": [1],
"echo": False,
"frequency_penalty": 123,
"logit_bias": {},
"logprobs": 123,
"max_tokens": 16,
"n": 1,
"presence_penalty": 123,
"seed": 0,
"stop": [],
"stream": False,
"stream_options": {
"include_usage": False,
"continuous_usage_stats": False
},
"suffix": "<string>",
"temperature": 123,
"top_p": 123,
"user": "<string>",
"use_beam_search": False,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"watermarking": True,
"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,
"allowed_token_ids": [123],
"prompt_logprobs": 123,
"logprob_token_ids": [123],
"bad_words": [],
"prompt_embeds": "<string>",
"add_special_tokens": True,
"response_format": { "json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": True
} },
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": ["<string>"],
"grammar": "<string>",
"json_object": True,
"disable_any_whitespace": False,
"disable_additional_properties": False,
"whitespace_pattern": "<string>",
"structural_tag": "<string>"
},
"priority": 0,
"request_id": "<string>",
"session_id": "<string>",
"return_tokens_as_token_ids": True,
"return_token_ids": True,
"cache_salt": "<string>",
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
},
"thinking_token_budget": 0,
"stream_interval": 2
}
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({
model: '<string>',
prompt: [1],
echo: false,
frequency_penalty: 123,
logit_bias: {},
logprobs: 123,
max_tokens: 16,
n: 1,
presence_penalty: 123,
seed: 0,
stop: [],
stream: false,
stream_options: {include_usage: false, continuous_usage_stats: false},
suffix: '<string>',
temperature: 123,
top_p: 123,
user: '<string>',
use_beam_search: false,
top_k: 123,
min_p: 123,
repetition_penalty: 123,
watermarking: true,
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,
allowed_token_ids: [123],
prompt_logprobs: 123,
logprob_token_ids: [123],
bad_words: [],
prompt_embeds: '<string>',
add_special_tokens: true,
response_format: {
json_schema: {name: '<string>', description: '<string>', schema: {}, strict: true}
},
structured_outputs: {
json: '<string>',
regex: '<string>',
choice: ['<string>'],
grammar: '<string>',
json_object: true,
disable_any_whitespace: false,
disable_additional_properties: false,
whitespace_pattern: '<string>',
structural_tag: '<string>'
},
priority: 0,
request_id: '<string>',
session_id: '<string>',
return_tokens_as_token_ids: true,
return_token_ids: true,
cache_salt: '<string>',
vllm_xargs: {},
repetition_detection: {max_pattern_size: 0, min_pattern_size: 0, min_count: 0},
thinking_token_budget: 0,
stream_interval: 2
})
};
fetch('https://inference.api.nscale.com/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://inference.api.nscale.com/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' => [
1
],
'echo' => false,
'frequency_penalty' => 123,
'logit_bias' => [
],
'logprobs' => 123,
'max_tokens' => 16,
'n' => 1,
'presence_penalty' => 123,
'seed' => 0,
'stop' => [
],
'stream' => false,
'stream_options' => [
'include_usage' => false,
'continuous_usage_stats' => false
],
'suffix' => '<string>',
'temperature' => 123,
'top_p' => 123,
'user' => '<string>',
'use_beam_search' => false,
'top_k' => 123,
'min_p' => 123,
'repetition_penalty' => 123,
'watermarking' => true,
'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,
'allowed_token_ids' => [
123
],
'prompt_logprobs' => 123,
'logprob_token_ids' => [
123
],
'bad_words' => [
],
'prompt_embeds' => '<string>',
'add_special_tokens' => true,
'response_format' => [
'json_schema' => [
'name' => '<string>',
'description' => '<string>',
'schema' => [
],
'strict' => true
]
],
'structured_outputs' => [
'json' => '<string>',
'regex' => '<string>',
'choice' => [
'<string>'
],
'grammar' => '<string>',
'json_object' => true,
'disable_any_whitespace' => false,
'disable_additional_properties' => false,
'whitespace_pattern' => '<string>',
'structural_tag' => '<string>'
],
'priority' => 0,
'request_id' => '<string>',
'session_id' => '<string>',
'return_tokens_as_token_ids' => true,
'return_token_ids' => true,
'cache_salt' => '<string>',
'vllm_xargs' => [
],
'repetition_detection' => [
'max_pattern_size' => 0,
'min_pattern_size' => 0,
'min_count' => 0
],
'thinking_token_budget' => 0,
'stream_interval' => 2
]),
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://inference.api.nscale.com/v1/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": [\n 1\n ],\n \"echo\": false,\n \"frequency_penalty\": 123,\n \"logit_bias\": {},\n \"logprobs\": 123,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 123,\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": false,\n \"continuous_usage_stats\": false\n },\n \"suffix\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"watermarking\": true,\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 \"allowed_token_ids\": [\n 123\n ],\n \"prompt_logprobs\": 123,\n \"logprob_token_ids\": [\n 123\n ],\n \"bad_words\": [],\n \"prompt_embeds\": \"<string>\",\n \"add_special_tokens\": true,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\"\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n },\n \"thinking_token_budget\": 0,\n \"stream_interval\": 2\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://inference.api.nscale.com/v1/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": [\n 1\n ],\n \"echo\": false,\n \"frequency_penalty\": 123,\n \"logit_bias\": {},\n \"logprobs\": 123,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 123,\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": false,\n \"continuous_usage_stats\": false\n },\n \"suffix\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"watermarking\": true,\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 \"allowed_token_ids\": [\n 123\n ],\n \"prompt_logprobs\": 123,\n \"logprob_token_ids\": [\n 123\n ],\n \"bad_words\": [],\n \"prompt_embeds\": \"<string>\",\n \"add_special_tokens\": true,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\"\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n },\n \"thinking_token_budget\": 0,\n \"stream_interval\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://inference.api.nscale.com/v1/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 \"model\": \"<string>\",\n \"prompt\": [\n 1\n ],\n \"echo\": false,\n \"frequency_penalty\": 123,\n \"logit_bias\": {},\n \"logprobs\": 123,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 123,\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": false,\n \"continuous_usage_stats\": false\n },\n \"suffix\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"watermarking\": true,\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 \"allowed_token_ids\": [\n 123\n ],\n \"prompt_logprobs\": 123,\n \"logprob_token_ids\": [\n 123\n ],\n \"bad_words\": [],\n \"prompt_embeds\": \"<string>\",\n \"add_special_tokens\": true,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\"\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n },\n \"thinking_token_budget\": 0,\n \"stream_interval\": 2\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"choices": [
{
"index": 123,
"text": "<string>",
"logprobs": {
"text_offset": [],
"token_logprobs": [],
"tokens": [],
"top_logprobs": []
},
"finish_reason": "<string>",
"stop_reason": 123,
"token_ids": [
123
],
"prompt_logprobs": [
{}
],
"prompt_token_ids": [
123
],
"routed_experts": "<string>"
}
],
"usage": {
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 123,
"created_cache_tokens": 123,
"multimodal_tokens": {}
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"id": "<string>",
"object": "text_completion",
"created": 123,
"service_tier": "auto",
"system_fingerprint": "<string>",
"metrics": {
"time_to_first_token_ms": 123,
"generation_time_ms": 123,
"queue_time_ms": 123,
"mean_itl_ms": 123,
"tokens_per_second": 123,
"speculative_decoding": {
"mean_acceptance_length": 123,
"draft_acceptance_rate": 123,
"acceptance_histogram": [
123
],
"num_spec_steps": 123,
"num_accepted_draft_tokens": 123,
"num_draft_tokens": 123,
"num_spec_tokens": 123,
"per_step_accepted": [
123
],
"per_step_drafted": [
123
]
}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Create a text completion
Creates a legacy text completion. Successful streams end with data: [DONE]. An idle timeout may instead end the stream with an error event.
curl --request POST \
--url https://inference.api.nscale.com/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": [
1
],
"echo": false,
"frequency_penalty": 123,
"logit_bias": {},
"logprobs": 123,
"max_tokens": 16,
"n": 1,
"presence_penalty": 123,
"seed": 0,
"stop": [],
"stream": false,
"stream_options": {
"include_usage": false,
"continuous_usage_stats": false
},
"suffix": "<string>",
"temperature": 123,
"top_p": 123,
"user": "<string>",
"use_beam_search": false,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"watermarking": true,
"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,
"allowed_token_ids": [
123
],
"prompt_logprobs": 123,
"logprob_token_ids": [
123
],
"bad_words": [],
"prompt_embeds": "<string>",
"add_special_tokens": true,
"response_format": {
"json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
}
},
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": [
"<string>"
],
"grammar": "<string>",
"json_object": true,
"disable_any_whitespace": false,
"disable_additional_properties": false,
"whitespace_pattern": "<string>",
"structural_tag": "<string>"
},
"priority": 0,
"request_id": "<string>",
"session_id": "<string>",
"return_tokens_as_token_ids": true,
"return_token_ids": true,
"cache_salt": "<string>",
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
},
"thinking_token_budget": 0,
"stream_interval": 2
}
'import requests
url = "https://inference.api.nscale.com/v1/completions"
payload = {
"model": "<string>",
"prompt": [1],
"echo": False,
"frequency_penalty": 123,
"logit_bias": {},
"logprobs": 123,
"max_tokens": 16,
"n": 1,
"presence_penalty": 123,
"seed": 0,
"stop": [],
"stream": False,
"stream_options": {
"include_usage": False,
"continuous_usage_stats": False
},
"suffix": "<string>",
"temperature": 123,
"top_p": 123,
"user": "<string>",
"use_beam_search": False,
"top_k": 123,
"min_p": 123,
"repetition_penalty": 123,
"watermarking": True,
"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,
"allowed_token_ids": [123],
"prompt_logprobs": 123,
"logprob_token_ids": [123],
"bad_words": [],
"prompt_embeds": "<string>",
"add_special_tokens": True,
"response_format": { "json_schema": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": True
} },
"structured_outputs": {
"json": "<string>",
"regex": "<string>",
"choice": ["<string>"],
"grammar": "<string>",
"json_object": True,
"disable_any_whitespace": False,
"disable_additional_properties": False,
"whitespace_pattern": "<string>",
"structural_tag": "<string>"
},
"priority": 0,
"request_id": "<string>",
"session_id": "<string>",
"return_tokens_as_token_ids": True,
"return_token_ids": True,
"cache_salt": "<string>",
"vllm_xargs": {},
"repetition_detection": {
"max_pattern_size": 0,
"min_pattern_size": 0,
"min_count": 0
},
"thinking_token_budget": 0,
"stream_interval": 2
}
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({
model: '<string>',
prompt: [1],
echo: false,
frequency_penalty: 123,
logit_bias: {},
logprobs: 123,
max_tokens: 16,
n: 1,
presence_penalty: 123,
seed: 0,
stop: [],
stream: false,
stream_options: {include_usage: false, continuous_usage_stats: false},
suffix: '<string>',
temperature: 123,
top_p: 123,
user: '<string>',
use_beam_search: false,
top_k: 123,
min_p: 123,
repetition_penalty: 123,
watermarking: true,
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,
allowed_token_ids: [123],
prompt_logprobs: 123,
logprob_token_ids: [123],
bad_words: [],
prompt_embeds: '<string>',
add_special_tokens: true,
response_format: {
json_schema: {name: '<string>', description: '<string>', schema: {}, strict: true}
},
structured_outputs: {
json: '<string>',
regex: '<string>',
choice: ['<string>'],
grammar: '<string>',
json_object: true,
disable_any_whitespace: false,
disable_additional_properties: false,
whitespace_pattern: '<string>',
structural_tag: '<string>'
},
priority: 0,
request_id: '<string>',
session_id: '<string>',
return_tokens_as_token_ids: true,
return_token_ids: true,
cache_salt: '<string>',
vllm_xargs: {},
repetition_detection: {max_pattern_size: 0, min_pattern_size: 0, min_count: 0},
thinking_token_budget: 0,
stream_interval: 2
})
};
fetch('https://inference.api.nscale.com/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://inference.api.nscale.com/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' => [
1
],
'echo' => false,
'frequency_penalty' => 123,
'logit_bias' => [
],
'logprobs' => 123,
'max_tokens' => 16,
'n' => 1,
'presence_penalty' => 123,
'seed' => 0,
'stop' => [
],
'stream' => false,
'stream_options' => [
'include_usage' => false,
'continuous_usage_stats' => false
],
'suffix' => '<string>',
'temperature' => 123,
'top_p' => 123,
'user' => '<string>',
'use_beam_search' => false,
'top_k' => 123,
'min_p' => 123,
'repetition_penalty' => 123,
'watermarking' => true,
'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,
'allowed_token_ids' => [
123
],
'prompt_logprobs' => 123,
'logprob_token_ids' => [
123
],
'bad_words' => [
],
'prompt_embeds' => '<string>',
'add_special_tokens' => true,
'response_format' => [
'json_schema' => [
'name' => '<string>',
'description' => '<string>',
'schema' => [
],
'strict' => true
]
],
'structured_outputs' => [
'json' => '<string>',
'regex' => '<string>',
'choice' => [
'<string>'
],
'grammar' => '<string>',
'json_object' => true,
'disable_any_whitespace' => false,
'disable_additional_properties' => false,
'whitespace_pattern' => '<string>',
'structural_tag' => '<string>'
],
'priority' => 0,
'request_id' => '<string>',
'session_id' => '<string>',
'return_tokens_as_token_ids' => true,
'return_token_ids' => true,
'cache_salt' => '<string>',
'vllm_xargs' => [
],
'repetition_detection' => [
'max_pattern_size' => 0,
'min_pattern_size' => 0,
'min_count' => 0
],
'thinking_token_budget' => 0,
'stream_interval' => 2
]),
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://inference.api.nscale.com/v1/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": [\n 1\n ],\n \"echo\": false,\n \"frequency_penalty\": 123,\n \"logit_bias\": {},\n \"logprobs\": 123,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 123,\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": false,\n \"continuous_usage_stats\": false\n },\n \"suffix\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"watermarking\": true,\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 \"allowed_token_ids\": [\n 123\n ],\n \"prompt_logprobs\": 123,\n \"logprob_token_ids\": [\n 123\n ],\n \"bad_words\": [],\n \"prompt_embeds\": \"<string>\",\n \"add_special_tokens\": true,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\"\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n },\n \"thinking_token_budget\": 0,\n \"stream_interval\": 2\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://inference.api.nscale.com/v1/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": [\n 1\n ],\n \"echo\": false,\n \"frequency_penalty\": 123,\n \"logit_bias\": {},\n \"logprobs\": 123,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 123,\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": false,\n \"continuous_usage_stats\": false\n },\n \"suffix\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"watermarking\": true,\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 \"allowed_token_ids\": [\n 123\n ],\n \"prompt_logprobs\": 123,\n \"logprob_token_ids\": [\n 123\n ],\n \"bad_words\": [],\n \"prompt_embeds\": \"<string>\",\n \"add_special_tokens\": true,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\"\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n },\n \"thinking_token_budget\": 0,\n \"stream_interval\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://inference.api.nscale.com/v1/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 \"model\": \"<string>\",\n \"prompt\": [\n 1\n ],\n \"echo\": false,\n \"frequency_penalty\": 123,\n \"logit_bias\": {},\n \"logprobs\": 123,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 123,\n \"seed\": 0,\n \"stop\": [],\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": false,\n \"continuous_usage_stats\": false\n },\n \"suffix\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"user\": \"<string>\",\n \"use_beam_search\": false,\n \"top_k\": 123,\n \"min_p\": 123,\n \"repetition_penalty\": 123,\n \"watermarking\": true,\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 \"allowed_token_ids\": [\n 123\n ],\n \"prompt_logprobs\": 123,\n \"logprob_token_ids\": [\n 123\n ],\n \"bad_words\": [],\n \"prompt_embeds\": \"<string>\",\n \"add_special_tokens\": true,\n \"response_format\": {\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n }\n },\n \"structured_outputs\": {\n \"json\": \"<string>\",\n \"regex\": \"<string>\",\n \"choice\": [\n \"<string>\"\n ],\n \"grammar\": \"<string>\",\n \"json_object\": true,\n \"disable_any_whitespace\": false,\n \"disable_additional_properties\": false,\n \"whitespace_pattern\": \"<string>\",\n \"structural_tag\": \"<string>\"\n },\n \"priority\": 0,\n \"request_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"return_tokens_as_token_ids\": true,\n \"return_token_ids\": true,\n \"cache_salt\": \"<string>\",\n \"vllm_xargs\": {},\n \"repetition_detection\": {\n \"max_pattern_size\": 0,\n \"min_pattern_size\": 0,\n \"min_count\": 0\n },\n \"thinking_token_budget\": 0,\n \"stream_interval\": 2\n}"
response = http.request(request)
puts response.read_body{
"model": "<string>",
"choices": [
{
"index": 123,
"text": "<string>",
"logprobs": {
"text_offset": [],
"token_logprobs": [],
"tokens": [],
"top_logprobs": []
},
"finish_reason": "<string>",
"stop_reason": 123,
"token_ids": [
123
],
"prompt_logprobs": [
{}
],
"prompt_token_ids": [
123
],
"routed_experts": "<string>"
}
],
"usage": {
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 123,
"created_cache_tokens": 123,
"multimodal_tokens": {}
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"id": "<string>",
"object": "text_completion",
"created": 123,
"service_tier": "auto",
"system_fingerprint": "<string>",
"metrics": {
"time_to_first_token_ms": 123,
"generation_time_ms": 123,
"queue_time_ms": 123,
"mean_itl_ms": 123,
"tokens_per_second": 123,
"speculative_decoding": {
"mean_acceptance_length": 123,
"draft_acceptance_rate": 123,
"acceptance_histogram": [
123
],
"num_spec_steps": 123,
"num_accepted_draft_tokens": 123,
"num_draft_tokens": 123,
"num_spec_tokens": 123,
"per_step_accepted": [
123
],
"per_step_drafted": [
123
]
}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Authorizations
Headers
Selects the caller's public-cloud organization. Required when the caller belongs to multiple public-cloud organizations and the URL does not select an organization; omission then returns 400. With one public-cloud organization, omission selects it automatically. An explicitly supplied value, including an empty value, that is not one of the caller's public-cloud organizations returns 403. On /organizations/{organization_id}/endpoints, the path organization_id takes precedence over this header.
1Body
Specific vocab token IDs to return logprobs for at each generated position, in addition to the sampled token. More efficient than requesting the full vocab when only a small fixed label set is needed (e.g. multilabel scoring where each label corresponds to a known vocab id). When set, this explicit token selection takes precedence over the natural top-k selected by logprobs. Requires logprobs to be set.
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).
1 - 1024Parameters 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 inference. Feature availability depends on the selected model.
Was this page helpful?