POST
/
v4
/
beta
/
completions

Authorizations

x-api-key
string
headerrequired

Body

application/json
prompt
string
required

Prompt for which to generate the completion.

Good prompt engineering is crucial to getting performant results from the model. If you are having trouble getting the model to perform well, try writing a more specific prompt here before trying more expensive techniques such as swapping in other models or finetuning the underlying LLM.

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

max_new_tokens
integer
temperature
number

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

stop_sequences
string[]
return_token_log_probs
boolean
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.

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.

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.

top_k
integer

Only sample from the top K options for each subsequent token

include_stop_str_in_output
boolean
guided_json
object
guided_regex
string
guided_choice
string[]
guided_grammar
string
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.

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.

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.

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

Response

200 - application/json
choices
object[]
required

The list of completions.

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.