POST
/
completions
Create completion
curl --request POST \
  --url https://api.openai.com/v1/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "<string>",
  "prompt": "This is a test.",
  "best_of": 1,
  "echo": false,
  "frequency_penalty": 0,
  "logit_bias": null,
  "logprobs": null,
  "max_tokens": 16,
  "n": 1,
  "presence_penalty": 0,
  "seed": 123,
  "stop": "\n",
  "stream": false,
  "stream_options": null,
  "suffix": "test.",
  "temperature": 1,
  "top_p": 1,
  "user": "user-1234"
}'
{
  "id": "<string>",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 123,
      "logprobs": {
        "text_offset": [
          123
        ],
        "token_logprobs": [
          123
        ],
        "tokens": [
          "<string>"
        ],
        "top_logprobs": [
          {}
        ]
      },
      "text": "<string>"
    }
  ],
  "created": 123,
  "model": "<string>",
  "system_fingerprint": "<string>",
  "object": "text_completion",
  "usage": {
    "completion_tokens": 0,
    "prompt_tokens": 0,
    "total_tokens": 0,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Response

200 - application/json

OK

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