Skip to main content
POST
/
openai
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://api.example.com/openai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}
'
{
  "choices": [
    {
      "finish_reason": "<string>",
      "index": 123,
      "delta": {
        "content": "<unknown>",
        "tool_call_id": "<string>",
        "tool_calls": [
          {
            "function": {
              "arguments": "<string>",
              "name": "<string>"
            },
            "type": "function",
            "id": "<string>"
          }
        ]
      },
      "message": {
        "content": "<unknown>",
        "tool_call_id": "<string>",
        "tool_calls": [
          {
            "function": {
              "arguments": "<string>",
              "name": "<string>"
            },
            "type": "function",
            "id": "<string>"
          }
        ]
      }
    }
  ],
  "created": 123,
  "model": "<string>",
  "object": "<string>",
  "$schema": "<string>",
  "usage": {
    "completion_tokens": 123,
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}

Authorizations

Authorization
string
header
required

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

Body

model
string
required

The model to use for the completion.

stream
boolean

If true, the response will be streamed as a series of events instead of a single JSON object.

stream_options
object

Options for streaming response. Only set this when you set stream: true.

Response

Successful response - JSON when stream=false, SSE when stream=true

choices
object[]
required

A list of chat completions from the model.

Minimum array length: 1
created
integer<int64>
required

The Unix timestamp (in seconds) when the completion was created.

model
string
required

The model used for the chat completion.

object
string
required

The object type 'chat.completion' or ''chat.completion.chunk'

$schema
string<uri>
read-only

A URL to the JSON Schema for this object.

Example:

"https://example.com/openai/schemas/ChatCompletion.json"

usage
object

Usage statistics for the chat completion.