POST
/
v4
/
beta
/
chat
/
completions

Authorizations

x-api-key
string
headerrequired

Body

application/json
model
string
required

The name of the model.

Should be formatted as vendor/model_name or vendor/model_name/deployment (ie: openai/gpt-3.5-turbo).

messages
object[]
required

The list of messages in the conversation.

Expand each message type to see how it works and when to use it. Most conversations should begin with a single user message.

chat_template
string

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 model's tokenizer does not define one and no override template is given

chat_template_kwargs
object

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

guided_json
object

JSON schema for guided decoding. Only supported in vllm.

guided_regex
string

Regex for guided decoding. Only supported in vllm.

guided_choice
string[]

Choices for guided decoding. Only supported in vllm.

guided_grammar
string

Context-free grammar for guided decoding. Only supported in vllm.

guided_decoding_backend
string

If specified, will override the default guided decoding backend of the server for this specific request. If set, must be either 'outlines' / 'lm-format-enforcer'

guided_whitespace_pattern
string

If specified, will override the default whitespace pattern for guided json decoding.

include_stop_str_in_output
boolean

Whether to include the stop string in the output.

memory_strategy
object

The memory strategy to use for the conversation. A memory strategy is a way to prevent the underlying LLM's context limit from being exceeded. Only the last_k memory strategy is supported at this time.

stream
boolean
default: false

Whether or not to stream the response.

Setting this to True will stream the response in real-time.

stream_options
object

Customize streaming behavior

stop

Up to 4 sequences where the API will stop generating further tokens.

frequency_penalty
number

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_bias
object

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.

logprobs
boolean

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_logprobs
integer

An integer between 0 and 20 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_tokens
integer

The maximum number of tokens that can be generated.

The token count of your prompt plus max_tokens cannot exceed the model's context length.

n
integer

How many completions to generate for each prompt.

Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.

presence_penalty
number

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.

seed
integer

If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.

suffix
string

The suffix that comes after a completion of inserted text.This parameter is only supported for gpt-3.5-turbo-instruct.

temperature
number

The sampling temperature to use for the completion. Higher values mean the model will take more risks.

top_p
number

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.

It is generally recommended to alter this or temperature but not both.

response_format
object

An object specifying the format that the model must output

user
string

A unique identifier representing your end-user.

audio
object

Audio-related parameters for chat completion

inference_timeout

Timeout for the API request

max_completion_tokens
integer

Maximum number of tokens to generate in the completion

modalities
enum<string>[]

List of modalities for the chat completion

Available options:
text,
audio
inference_extra_params
object

Additional params to be included in the API request

tools
object[]

Currently only supported for OpenAI and Anthropic models.A list of tools the model may call.Currently, only functions are supported as a tool.Use this to provide a list of functions the model may generate JSON inputs for.

tool_choice

Currently only supported for OpenAI and Anthropic models.Controls which (if any) tool is called by the model.

Available options:
none,
auto,
required
parallel_tool_calls
boolean

Currently only supported for OpenAI models.Enables calling tools in parallel.

best_of
integer

Generates best_of completions server-side and returns the best (the one with the highest log probability per token). Results cannot be streamed.

inference_extra_headers
object

Additional headers to be included in the API request

prediction
object

Configure a predicted output to reduce latency

top_k
integer

Only sample from the top K options for each subsequent token

Response

200 - application/json
choices
object[]
required
usage
object

Usage statistics.

id
string

A unique identifier for the completion.

model
string

The model used for completion.

object
string

The object type, ex text_completion or chat.completion

system_fingerprint
string

This fingerprint represents the backend configuration that the model runs with.

created
integer

The Unix timestamp (in seconds) of when the chat completion was created.