POST
/
v4
/
beta
/
completions

Authorizations

x-api-key
string
header
required

Body

application/json
model
string
required

model specified as model_vendor/model, for example openai/gpt-4o

prompt
required

The prompt to generate completions for, encoded as a string

best_of
integer

Generates best_of completions server-side and returns the best one. Must be greater than n when used together.

echo
boolean

Echo back the prompt in addition to the completion

frequency_penalty
number

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text.

logit_bias
object

Modify the likelihood of specified tokens appearing in the completion. Maps tokens to bias values from -100 to 100.

logprobs
integer

Include log probabilities of the most likely tokens. Maximum value is 5.

max_tokens
integer

The maximum number of tokens that can be generated in the completion.

n
integer

How many completions to generate for each prompt.

presence_penalty
number

Number between -2.0 and 2.0. Positive values penalize new tokens based on their presence in the text so far.

seed
integer

If specified, attempts to generate deterministic samples. Determinism is not guaranteed.

stop

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

stream
boolean

Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events.

stream_options
object

Options for streaming response. Only set this when stream is True.

suffix
string

The suffix that comes after a completion of inserted text. Only supported for gpt-3.5-turbo-instruct.

temperature
number

Sampling temperature between 0 and 2. Higher values make output more random, lower more focused.

top_p
number

Alternative to temperature. Consider only tokens with top_p probability mass. Range 0-1.

user
string

A unique identifier representing your end-user, which can help OpenAI monitor and detect abuse.

Response

200 - application/json
choices
object[]
required
created
integer
required
id
string
required
model
string
required
object
enum<string>
default:
text_completion
Available options:
text_completion
system_fingerprint
string
usage
object