Represents a completion response from the API. Note: both streaming and non-streaming response objects share the same structure (unlike the chat endpoint).

Object Fields

id
string
A unique identifier for the completion.
choices
array
The list of completion choices the model generated for the input prompt.Each choice object contains:
  • index (integer): The index of the choice in the list
  • text (string): The generated text
  • finish_reason (string): The reason the model stopped generating (stop, length)
created
integer
The Unix timestamp (in seconds) of when the completion was created.
model
string
The model used for the completion.
system_fingerprint
string
This fingerprint represents the backend configuration that the model runs with.
object
string
The object type, which is always text_completion.
usage
object
Usage statistics for the completion request.
  • completion_tokens (integer): Number of tokens in the generated completion
  • prompt_tokens (integer): Number of tokens in the prompt
  • total_tokens (integer): Total number of tokens used in the request (prompt + completion)

Example

{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1677652288,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "index": 0,
      "text": "\n\nThis is a test.",
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 5,
    "completion_tokens": 7,
    "total_tokens": 12
  },
  "system_fingerprint": "fp_44709d6fcb"
}