Skip to navigation

OpenAI-compatible chat endpoint

View as Markdown

Request

This endpoint expects an object.
messageslist of objectsRequired
A list of messages comprising the conversation so far.
modelstringRequired
The model to use.
frequency_penaltydouble or nullOptional-2-2Defaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.

logit_biasmap from strings to doubles or nullOptional

Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

logprobsboolean or nullOptionalDefaults to false

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.

top_logprobsinteger or nullOptional1-20

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.

max_tokensinteger or nullOptional>=1
The maximum number of tokens that can be generated.
ninteger or nullOptional1-128Defaults to 1
How many completions to generate for each prompt.
presence_penaltydouble or nullOptional-2-2Defaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.

response_formatobject or nullOptional

An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.

seedinteger or nullOptional-9223372036854776000-9223372036854776000
Changing the seed will produce a different response with similar characteristics. Fixing the seed will reproduce the same results if all other parameters are also kept constant.
stopstring or list of strings or nullOptional
Sequences where the API will stop generating further tokens.
streamboolean or nullOptionalDefaults to false

If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE]

stream_optionsobject or nullOptional
temperaturedouble or nullOptional0-2Defaults to 1
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
top_pdouble or nullOptional<=1Defaults to 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.

toolslist of objects or nullOptional
tool_choiceenum or object or nullOptionalDefaults to none

Controls which (if any) tool is called by the model.

parallel_tool_callsboolean or nullOptionalDefaults to true
userstring or nullOptional
min_pdoubleOptionalDefaults to 0
prompt_logprobsinteger or nullOptional
add_special_tokensbooleanOptionalDefaults to 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).

documentslist of maps from strings to strings or nullOptional

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_templatestring or nullOptional
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.
chat_template_kwargsobject or nullOptional
Additional kwargs to pass to the template renderer. Will be accessible by the chat template.
guided_whitespace_patternstring or nullOptional
If specified, will override the default whitespace pattern for guided json decoding.
nvextobject or nullOptional
Extension dictionary for NIM API.

Response

Successful Response
ChatCompletionResponseobject
OR
ChatCompletionStreamResponseobject

Errors

400
Bad Request Error
404
Not Found Error
415
Unsupported Media Type Error
422
Unprocessable Entity Error
500
Internal Server Error