Completions
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
Create completion
ModelsExpand Collapse
class Completion: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).
List<CompletionChoice> choicesThe list of completion choices the model generated for the input prompt.
The list of completion choices the model generated for the input prompt.
FinishReason finishReasonThe 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.
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.
class CompletionChoice:
FinishReason finishReasonThe 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.
class CompletionUsage:Usage statistics for the completion request.
Usage statistics for the completion request.
Optional<CompletionTokensDetails> completionTokensDetailsBreakdown 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.
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.