Messages
curl --request POST \
--url https://api.example.com/messages \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"max_tokens": 123,
"messages": [
{}
],
"system": "<string>",
"temperature": 123,
"stream": true,
"provider": {}
}
'import requests
url = "https://api.example.com/messages"
payload = {
"model": "<string>",
"max_tokens": 123,
"messages": [{}],
"system": "<string>",
"temperature": 123,
"stream": True,
"provider": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
max_tokens: 123,
messages: [{}],
system: '<string>',
temperature: 123,
stream: true,
provider: {}
})
};
fetch('https://api.example.com/messages', 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.example.com/messages",
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>',
'max_tokens' => 123,
'messages' => [
[
]
],
'system' => '<string>',
'temperature' => 123,
'stream' => true,
'provider' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"max_tokens\": 123,\n \"messages\": [\n {}\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"stream\": true,\n \"provider\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/messages")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"max_tokens\": 123,\n \"messages\": [\n {}\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"stream\": true,\n \"provider\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"max_tokens\": 123,\n \"messages\": [\n {}\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"stream\": true,\n \"provider\": {}\n}"
response = http.request(request)
puts response.read_bodyAPI Reference
Messages
Create a model response using the Anthropic Messages API format through the attested Private AI gateway.
POST
/
messages
Messages
curl --request POST \
--url https://api.example.com/messages \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"max_tokens": 123,
"messages": [
{}
],
"system": "<string>",
"temperature": 123,
"stream": true,
"provider": {}
}
'import requests
url = "https://api.example.com/messages"
payload = {
"model": "<string>",
"max_tokens": 123,
"messages": [{}],
"system": "<string>",
"temperature": 123,
"stream": True,
"provider": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
max_tokens: 123,
messages: [{}],
system: '<string>',
temperature: 123,
stream: true,
provider: {}
})
};
fetch('https://api.example.com/messages', 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.example.com/messages",
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>',
'max_tokens' => 123,
'messages' => [
[
]
],
'system' => '<string>',
'temperature' => 123,
'stream' => true,
'provider' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"max_tokens\": 123,\n \"messages\": [\n {}\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"stream\": true,\n \"provider\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/messages")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"max_tokens\": 123,\n \"messages\": [\n {}\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"stream\": true,\n \"provider\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"max_tokens\": 123,\n \"messages\": [\n {}\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"stream\": true,\n \"provider\": {}\n}"
response = http.request(request)
puts response.read_bodyCreates a model response using the Anthropic Messages request and response format. Requests are served through the attested gateway and return an
Read assistant text from
x-receipt-id header for verification.
Endpoint
POST https://inference.phala.com/v1/messages
Request Body
Model id returned by List Models.
Routing constraints for this request, applied together. If no provider satisfies the constraints the request fails before the prompt is sent, and failover retries stay inside the allowed set. Field reference: Chat Completions. See Attested Routing and Zero Data Retention.
zdr restricts routing to providers that do not retain content; aci_verified restricts it to an upstream verified inside the TEE; aci_session_ids pins it to specific attested channels.{"provider": {"aci_verified": true}}
Example
curl https://inference.phala.com/v1/messages \
-H "Authorization: Bearer $PHALA_AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-ai/glm-5.3",
"max_tokens": 100,
"messages": [
{"role": "user", "content": "Say hello in three words."}
]
}'
Response
{
"id": "msg_01ABC...",
"type": "message",
"role": "assistant",
"model": "z-ai/glm-5.3",
"content": [
{ "type": "text", "text": "Hello, howdy, hi!" }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": { "input_tokens": 14, "output_tokens": 8 }
}
content[].text on blocks with type: "text". stop_reason is usually end_turn, max_tokens, stop_sequence, or tool_use.
Verification
Use the responsex-receipt-id header with Get Receipt. A confidential response has upstream.verified.result = verified and required = true.
Related
Responses
Trust Boundary
Was this page helpful?

