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.3",
"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.3",
"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.3',
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.3',
'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.3\",\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.3\",\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.3\",\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,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_tokens_details": {},
"completion_tokens_details": {}
},
"service_tier": "asap"
}{
"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>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Create a chat completion
OpenAI-compatible Chat Completions endpoint. Supports streaming via stream: true, which returns a Server-Sent Events stream of chat.completion.chunk objects.
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.3",
"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.3",
"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.3',
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.3',
'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.3\",\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.3\",\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.3\",\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,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_tokens_details": {},
"completion_tokens_details": {}
},
"service_tier": "asap"
}{
"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>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Authorizations
Headers
Identifies one submission within your organization and API key. Reuse the same value and request body when retrying; use a new value for new work. See Idempotency.
255Service tier for this request, for clients that cannot set service_tier in the body. A tier in the body takes precedence. See Service tiers.
asap, balanced, flex Body
Service tier controls request scheduling and token pricing.
Defaults when omitted
- Core model inference:
asap(low latency). - Batch:
flex. Other tiers are rejected. - LoRA:
flex. Explicitbalancedorasapis rejected; use background Responses or Batch. - Background Responses: an available non-ASAP tier. Models that only support
asapare rejected. - Flex-only models:
flexis the default and only tier, including for Batch and LoRA.
Requirements
- An explicit tier must be supported by the model or Sail returns an error. See the Pricing support matrix.
- Use
flexthrough the Batch API or Responses withbackground: true. Synchronous Responses, Chat Completions, and Messages rejectflex. Background Responses cannot stream.
See default behavior and Flex request requirements for details.
asap, balanced, flex 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).