Skip to main content
POST
/
api
/
v1
/
chat
/
completions
Generate chat completion
curl --request POST \
  --url https://api.example.com/api/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {
      "content": "<string>",
      "role": "<string>",
      "name": "<string>",
      "completion_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
    }
  ],
  "model": "<string>",
  "stop": [
    "<string>"
  ],
  "max_tokens": 1,
  "temperature": 123,
  "top_p": 123,
  "serialized_python": "<string>",
  "stream": true,
  "stream_options": {
    "include_usage": true
  },
  "session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "user": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "ab_campaign": "76d1fab3-214c-47ef-bb04-16270639bf89",
  "n": 1,
  "labels": {
    "key": "value"
  },
  "metadata": {
    "key": "value"
  },
  "system_prompt_args": {},
  "tags": [
    "<string>"
  ]
}
'
{
  "id": "<string>",
  "created": "1720712536",
  "choices": [
    {
      "index": 1,
      "message": {
        "role": "<string>",
        "content": "<string>"
      },
      "completion_id": "<string>",
      "model": "<string>",
      "finish_reason": "<string>"
    }
  ],
  "session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "usage": {
    "completion_tokens": 1,
    "prompt_tokens": 1,
    "total_tokens": 1
  }
}

Body

application/json
messages
object[]
required
model
string
required

can be of the form {use_case}/{model} or {use_case}. In the latter it will use the default model

stop
string[] | null
max_tokens
integer<int32> | null
Required range: x >= 0
temperature
number<float> | null
top_p
number<float> | null
serialized_python
string | null
stream
boolean
stream_options
object
session_id
string<uuid> | null
user
string<uuid> | null
ab_campaign
string

id or key of the entity

Example:

"76d1fab3-214c-47ef-bb04-16270639bf89"

n
integer<int32>
Required range: x >= 0
labels
object

dictionnary with key and values as string

Example:
{ "key": "value" }
metadata
object

dictionnary with key and values as string

Example:
{ "key": "value" }
system_prompt_args
object

Will be used to render system prompt template

tags
string[] | null

Response

a stream will be returned if streaming = true in the request

id
string
required
created
number
required

Unix Timestamp in seconds

Example:

"1720712536"

choices
object[]
required
session_id
string<uuid>
required
usage
object
required