Skip to main content
POST
Create a chat completion

Authorizations

Authorization
string
header
required

Nscale bearer token supplied in the Authorization header.

Headers

X-Organization-Id
string

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.

Minimum string length: 1
X-Request-Id
string

Optional correlation identifier. Use the X-Request-Id returned in the response when contacting support. The response ID may differ from this value. Supplying this header does not make a request idempotent.

Body

application/json
messages
(Developer message · object | System message · object | User message · object | Assistant message · object | Tool message · object | Function message · object)[]
required
model
string
required

Model ID from GET /v1/models. Capabilities depend on the selected model.

Minimum string length: 1
frequency_penalty
number | null
logit_bias
object | null
logprobs
boolean | null
default:false
top_logprobs
integer | null
default:0
max_tokens
integer | null
deprecated
max_completion_tokens
integer | null
n
integer | null
default:1
presence_penalty
number | null
response_format
object
seed
integer
Required range: -9223372036854776000 <= x <= 9223372036854776000
stop
default:[]
stream
boolean | null
default:false
stream_options
object | null
temperature
number | null
top_p
number | null
tools
object[] | null
tool_choice

Defaults to none when tools are omitted or empty; defaults to auto when tools are supplied.

Available options:
none
reasoning_effort
enum<string> | null

Constrains effort on reasoning for reasoning models. Currently supported values are none, minimal, low, medium, high, xhigh, and max. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Note that 'max' is specific to the DeepSeek V4 series and is not part of the standard OpenAI API specification.

Available options:
none,
minimal,
low,
medium,
high,
xhigh,
max
thinking_token_budget
integer | null
Required range: x >= -1
include_reasoning
boolean
default:true
parallel_tool_calls
boolean | null
default:true
user
string | null
top_k
integer | null
min_p
number | null
repetition_penalty
number | null
watermarking
boolean | null
length_penalty
number
default:1
stop_token_ids
integer[] | null
include_stop_str_in_output
boolean
default:false
ignore_eos
boolean
default:false
min_tokens
integer
default:0
skip_special_tokens
boolean
default:true
spaces_between_special_tokens
boolean
default:true
truncate_prompt_tokens
integer | null
Required range: -1 <= x <= 9223372036854776000
truncation_side
enum<string> | null

Which side to truncate from when truncate_prompt_tokens is active. 'right' keeps the first N tokens. 'left' keeps the last N tokens.

Available options:
left,
right
prompt_logprobs
integer | null
logprob_token_ids
integer[] | null

Specific vocab token IDs to return logprobs for at each generated position, in addition to the sampled token. More efficient than top_logprobs=-1 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 top_logprobs. Requires logprobs=True.

allowed_token_ids
integer[] | null
bad_words
string[]
echo
boolean
default:false

If true, the new message will be prepended with the last message if they belong to the same role.

add_generation_prompt
boolean
default:true

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.

continue_final_message
boolean
default:false

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.

add_special_tokens
boolean
default:false

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).

documents
object[] | null

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.

chat_template
string | null

Jinja template for formatting conversation messages. Availability depends on the selected model.

chat_template_kwargs
object | null

Additional keyword args to pass to the template renderer. Will be accessible by the chat template.

media_io_kwargs
object | null

Model-specific options for reading image, audio and video inputs, keyed by modality.

mm_processor_kwargs
object | null

Model-specific options for processing image, audio and video inputs.

structured_outputs
object | null

Additional kwargs for structured outputs

priority
integer
default:0

Scheduling priority; lower values are handled first. Non-zero priorities require support from the selected model.

Required range: -9223372036854776000 <= x <= 9223372036854776000
request_id
string

Identifier for the generation request. Generated when omitted. This is separate from the X-Request-Id HTTP correlation header.

session_id
string | null

Stable session identity shared by related requests. Unlike request_id, this value is expected to remain stable across multiple requests in the same conversation or agent session.

return_tokens_as_token_ids
boolean | null

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.

return_token_ids
boolean | null

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.

return_prompt_text
boolean | null

If true, the response will include prompt_text containing the prompt string produced by chat templating. In streaming mode it is sent only on the first chunk. This is useful for inspecting exactly what was fed into the model.

cache_salt
string

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).

Required string length: 1 - 1024
vllm_xargs
object | null

Additional request parameters with (list of) string or numeric values, used by custom extensions.

repetition_detection
object | null

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.

stream_interval
integer | null

Minimum number of tokens per streamed chunk. The first and last chunks are sent immediately. The effective interval may be higher than requested. Ignored for non-streaming requests.

Required range: x >= 1

Response

Successful inference. Feature availability depends on the selected model.

id
string
required
object
enum<string>
default:chat.completion
required
Available options:
chat.completion
created
integer
required
model
string
required
choices
object[]
required
service_tier
enum<string> | null
Available options:
auto,
default,
flex,
scale,
priority
system_fingerprint
string | null
usage
object
prompt_logprobs
(object | null)[] | null
prompt_token_ids
integer[] | null
prompt_text
string | null
metrics
object | null