Completions
Create completion
ModelsExpand Collapse
Completion = object { id, choices, created, 4 more } Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).
Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).
A unique identifier for the completion.
The list of completion choices the model generated for the input prompt.
The list of completion choices the model generated for the input prompt.
finish_reason: "stop" or "length" or "content_filter"The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence,
length if the maximum number of tokens specified in the request was reached,
or content_filter if content was omitted due to a flag from our content filters.
The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence,
length if the maximum number of tokens specified in the request was reached,
or content_filter if content was omitted due to a flag from our content filters.
logprobs: object { text_offset, token_logprobs, tokens, top_logprobs }
The Unix timestamp (in seconds) of when the completion was created.
The model used for completion.
The object type, which is always "text_completion"
This fingerprint represents the backend configuration that the model runs with.
Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.
Usage statistics for the completion request.
CompletionChoice = object { finish_reason, index, logprobs, text }
finish_reason: "stop" or "length" or "content_filter"The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence,
length if the maximum number of tokens specified in the request was reached,
or content_filter if content was omitted due to a flag from our content filters.
The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence,
length if the maximum number of tokens specified in the request was reached,
or content_filter if content was omitted due to a flag from our content filters.
logprobs: object { text_offset, token_logprobs, tokens, top_logprobs }
CompletionUsage = object { completion_tokens, prompt_tokens, total_tokens, 2 more } Usage statistics for the completion request.
Usage statistics for the completion request.
Number of tokens in the generated completion.
Number of tokens in the prompt.
Total number of tokens used in the request (prompt + completion).
completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens } Breakdown of tokens used in a completion.
Breakdown of tokens used in a completion.
When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
Audio input tokens generated by the model.
Tokens generated by the model for reasoning.
When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
prompt_tokens_details: optional object { audio_tokens, cached_tokens } Breakdown of tokens used in the prompt.
Breakdown of tokens used in the prompt.
Audio input tokens present in the prompt.
Cached tokens present in the prompt.