POST
/
api
/
gateway
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
  --url http://localhost:3000/api/gateway/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "openai/gpt-4o-mini",
  "metadata": {
    "waystone": "{\n\t\t\t\t\t\t\"user\": {\n\t\t\t\t\t\t\t\"id\": \"user123\",\n\t\t\t\t\t\t\t\"metadata\": { \"email\": \"user@example.com\", \"name\": \"John Doe\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}"
  },
  "store": false,
  "stream": false,
  "user": "<string>",
  "temperature": 1,
  "frequency_penalty": 0,
  "max_completion_tokens": 123,
  "n": 1,
  "messages": [
    {
      "content": "<string>",
      "role": "developer",
      "name": "<string>"
    }
  ]
}'
{
  "choices": [
    {
      "finish_reason": "<string>",
      "index": 123,
      "logprobs": {},
      "message": {
        "contents": "<string>",
        "refusal": "<string>",
        "role": "<string>",
        "annotations": [
          {}
        ],
        "audio": {}
      },
      "created": 123
    }
  ],
  "id": "<string>",
  "object": "<string>",
  "model": "<string>",
  "usage": {
    "completion_tokens": 123,
    "prompt_tokens": 123,
    "total_tokens": 123,
    "completion_tokens_details": {},
    "prompt_tokens_details": {}
  }
}

Authorizations

Authorization
string
header
required

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

Body

application/json
model
string
required

<provider>/<model> to use in the query. If <model> is unique across providers, can supply <model> only

Examples:

"openai/gpt-4o-mini"

"gpt-4o-mini"

messages
object[]
required

A list of messages comprising the conversation so far.

metadata
object

Key-value pairs of metadata for the request. Identify end-users associated with the query with the waystone metadata. All other fields are metadata for OpenAI requests and are not used by Waystone.

Examples:
{
"waystone": "{\n\t\t\t\t\t\t\"user\": {\n\t\t\t\t\t\t\t\"id\": \"user123\",\n\t\t\t\t\t\t\t\"metadata\": { \"email\": \"user@example.com\", \"name\": \"John Doe\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}"
}
{
"waystone": "{\n\t\t\t\t\t\t\"user\": \"user123\",\n\t\t\t\t\t\t\"group\": { \"id\": \"group123\", \"metadata\": { \"name\": \"Group Name\" } }\n\t\t\t\t\t}"
}
store
boolean | null
default:false

For OpenAI: Whether or not to store the output of this chat completion request in OpenAI

stream
boolean | null
default:false

If set to true, the model response data will be streamed to the client as it is generated

user
string

For OpenAI: A unique identifier representing your end-user. NOT used by Waystone.

temperature
number
default:1

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.

Required range: 0 <= x <= 2
frequency_penalty
number
default:0

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

Required range: -2 <= x <= 2
max_completion_tokens
number

An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.

n
number
default:1

How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.

Response

200 - application/json

Successful response

choices
object[]
required
Minimum length: 1
id
string
required

The unique identifier for the chat completion, generated by the model provider.

object
string
required
model
string
required

The model name used to generate the response.

usage
object
required