Skip to main content
POST
/
chat
/
completions
Create a chat completion
curl --request POST \
  --url https://api.sailresearch.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "zai-org/GLM-5.2-FP8",
  "messages": [
    {
      "role": "system",
      "content": "You are a concise assistant."
    },
    {
      "role": "user",
      "content": "Summarize retrieval-augmented generation in 3 bullets."
    }
  ],
  "max_completion_tokens": 300
}
'
import requests

url = "https://api.sailresearch.com/v1/chat/completions"

payload = {
"model": "zai-org/GLM-5.2-FP8",
"messages": [
{
"role": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Summarize retrieval-augmented generation in 3 bullets."
}
],
"max_completion_tokens": 300
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'zai-org/GLM-5.2-FP8',
messages: [
{role: 'system', content: 'You are a concise assistant.'},
{
role: 'user',
content: 'Summarize retrieval-augmented generation in 3 bullets.'
}
],
max_completion_tokens: 300
})
};

fetch('https://api.sailresearch.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sailresearch.com/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'zai-org/GLM-5.2-FP8',
'messages' => [
[
'role' => 'system',
'content' => 'You are a concise assistant.'
],
[
'role' => 'user',
'content' => 'Summarize retrieval-augmented generation in 3 bullets.'
]
],
'max_completion_tokens' => 300
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sailresearch.com/v1/chat/completions"

payload := strings.NewReader("{\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Summarize retrieval-augmented generation in 3 bullets.\"\n }\n ],\n \"max_completion_tokens\": 300\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sailresearch.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Summarize retrieval-augmented generation in 3 bullets.\"\n }\n ],\n \"max_completion_tokens\": 300\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.sailresearch.com/v1/chat/completions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Summarize retrieval-augmented generation in 3 bullets.\"\n }\n ],\n \"max_completion_tokens\": 300\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "object": "chat.completion",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "assistant",
        "content": "<string>",
        "reasoning_content": "<string>",
        "refusal": "<string>"
      },
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "prompt_tokens_details": {},
    "completion_tokens_details": {}
  }
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}

Authorizations

Authorization
string
header
required

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

Headers

Idempotency-Key
string

Makes the request retry-safe. Sail stores a reservation keyed by (organization, API key, Idempotency-Key); retrying with the same value returns the previously stored response instead of re-running inference. Keys are capped at 255 characters. See Idempotent Requests for full semantics.

Maximum string length: 255

Body

application/json
model
string
required
messages
object[]
required
Minimum array length: 1
temperature
number | null
Required range: 0 <= x <= 2
top_p
number | null
Required range: 0 <= x <= 1
max_completion_tokens
integer | null
Required range: x >= 1
response_format
object
reasoning_effort
enum<string> | null
Available options:
none,
minimal,
low,
medium,
high,
xhigh
n
enum<integer>

Only n=1 is currently supported.

Available options:
1
modalities
enum<string>[]
Required array length: 1 element
Available options:
text
stream
boolean

When true, the response is returned as a Server-Sent Events stream of chat.completion.chunk objects instead of a single JSON response.

stream_options
object

Options that apply when stream is true.

store
enum<boolean>

Only true is supported.

Available options:
true
user
string
Maximum string length: 256
metadata
object

Optional string metadata. completion_window controls scheduling; completion_webhook/webhook_token configure completion webhooks.

Response

Chat completion. Returns a single JSON object by default, or a Server-Sent Events stream of chat.completion.chunk objects when stream: true (terminated by a final data: [DONE] line).

id
string
required
object
enum<string>
required
Available options:
chat.completion
created
integer
required
model
string
required
choices
object[]
required
Minimum array length: 1
usage
object