Chat completions
curl --request POST \
--url https://api.redpill.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"temperature": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"stream": true,
"top_p": 123,
"n": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"provider": {}
}
'import requests
url = "https://api.redpill.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"temperature": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"stream": True,
"top_p": 123,
"n": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"provider": {}
}
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: '<string>',
messages: [{}],
temperature: 123,
max_tokens: 123,
max_completion_tokens: 123,
stream: true,
top_p: 123,
n: 123,
presence_penalty: 123,
frequency_penalty: 123,
provider: {}
})
};
fetch('https://api.redpill.ai/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.redpill.ai/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' => '<string>',
'messages' => [
[
]
],
'temperature' => 123,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'stream' => true,
'top_p' => 123,
'n' => 123,
'presence_penalty' => 123,
'frequency_penalty' => 123,
'provider' => [
]
]),
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.redpill.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"n\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"provider\": {}\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.redpill.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"n\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"provider\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.redpill.ai/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\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"n\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"provider\": {}\n}"
response = http.request(request)
puts response.read_bodyEndpoints
Chat completions
Create chat completion responses.
POST
/
chat
/
completions
Chat completions
curl --request POST \
--url https://api.redpill.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"temperature": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"stream": true,
"top_p": 123,
"n": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"provider": {}
}
'import requests
url = "https://api.redpill.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"temperature": 123,
"max_tokens": 123,
"max_completion_tokens": 123,
"stream": True,
"top_p": 123,
"n": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"provider": {}
}
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: '<string>',
messages: [{}],
temperature: 123,
max_tokens: 123,
max_completion_tokens: 123,
stream: true,
top_p: 123,
n: 123,
presence_penalty: 123,
frequency_penalty: 123,
provider: {}
})
};
fetch('https://api.redpill.ai/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.redpill.ai/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' => '<string>',
'messages' => [
[
]
],
'temperature' => 123,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'stream' => true,
'top_p' => 123,
'n' => 123,
'presence_penalty' => 123,
'frequency_penalty' => 123,
'provider' => [
]
]),
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.redpill.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"n\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"provider\": {}\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.redpill.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"n\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"provider\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.redpill.ai/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\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"n\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"provider\": {}\n}"
response = http.request(request)
puts response.read_bodyCreates a model response for the given chat conversation. Requests are served through the attested TEE gateway, which does not retain request bodies. A confidential response additionally runs on a verified upstream enclave, confirmed per response from the receipt’s
upstream.verified event. The response includes an x-receipt-id header for verification.
POST https://api.redpill.ai/v1/chat/completions
Request body
string
default:"z-ai/glm-5.2"
required
Model ID returned by
GET /v1/models.array
required
Array of message objects. Each message needs With system message:
role and content.Example:[
{"role": "user", "content": "What is confidential AI?"}
]
[
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello!"}
]
number
Sampling temperature (0-2), default 1
integer
Maximum tokens to generateOpenAI
gpt-5, o3, and o4 models reject it; send max_completion_tokens instead.integer
Maximum tokens to generate, for OpenAI
gpt-5, o3, and o4 models. Each model object’s
supported_parameters lists which of the two it accepts.boolean
Stream responses, default false
number
Nucleus sampling (0-1)
integer
Number of completions, default 1
number
Presence penalty (-2 to 2)
number
Frequency penalty (-2 to 2)
object
Routing constraints for this request. Fields are applied together, and the request is served only
by a provider that satisfies all of them.If no provider for the model satisfies the constraint, the request returns If no upstream for the model is both classified as attested and currently verified, the request
returns Session ids imply
zdr (boolean): set true to route only to providers that operate under zero data retention,
meaning they do not retain prompt or completion content after serving the request. false, or
omitting the field, applies no retention constraint.{"provider": {"zdr": true}}
404 and no prompt is
sent. The constraint is enforced for the whole request, including failover, so a retry cannot fall
back to a provider that does not satisfy it.Find models that can satisfy zdr ahead of time with
GET /v1/models?zdr=true. See
Zero data retention.aci_verified (boolean): set true to route only to an upstream the gateway verified inside
the TEE before sending the prompt. false, or omitting the field, applies no attestation
constraint.{"provider": {"aci_verified": true}}
503 and no prompt is sent. X-Upstream-Verification: none cannot relax this constraint.aci_session_ids (array of strings): restrict the request further to specific attested
channels, identified by the session ids from
GET /v1/aci/sessions. Any one of the listed ids may serve the
request; if none matches a currently verified channel, the request returns 503.{"provider": {"aci_verified": true, "aci_session_ids": ["2a44...6290"]}}
aci_verified. Passing them with "aci_verified": false returns 400, as does
an empty array or a non-string entry. Both fields are read by the gateway and removed before the
request reaches a provider. See Attested routing.Message object
{
"role": "user" | "assistant" | "system",
"content": "string" | array
}
Examples
curl https://api.redpill.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $REDPILL_AI_API_KEY" \
-d '{
"model": "z-ai/glm-5.2",
"messages": [
{"role": "user", "content": "What is confidential AI?"}
]
}'
curl https://api.redpill.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $REDPILL_AI_API_KEY" \
-d '{
"model": "openai/gpt-5",
"messages": [
{"role": "user", "content": "What is confidential AI?"}
]
}'
curl https://api.redpill.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $REDPILL_AI_API_KEY" \
-d '{
"model": "anthropic/claude-sonnet-4.5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain TEE"}
],
"temperature": 0.7,
"max_tokens": 500
}'
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["REDPILL_AI_API_KEY"],
base_url="https://api.redpill.ai/v1"
)
response = client.chat.completions.create(
model="openai/gpt-5",
messages=[
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Hello!"}
],
temperature=0.7,
max_tokens=100
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.redpill.ai/v1',
apiKey: process.env.REDPILL_AI_API_KEY
});
const response = await client.chat.completions.create({
model: 'openai/gpt-5',
messages: [
{ role: 'system', content: 'You are helpful.' },
{ role: 'user', content: 'Hello!' }
],
temperature: 0.7,
max_tokens: 100
});
console.log(response.choices[0].message.content);
Response
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "openai/gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Confidential AI is a privacy-first approach to inference..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 25,
"total_tokens": 38
}
}
Related
Streaming
Function calling
Vision
Error handling
Was this page helpful?