Create chat completion (pod OpenAI adapter)
curl --request POST \
--url https://compute.x402layer.cc/pods/{id}/v1/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "user",
"content": "What can you do?"
}
],
"model": "agent-pod",
"stream": false
}
'import requests
url = "https://compute.x402layer.cc/pods/{id}/v1/chat/completions"
payload = {
"messages": [
{
"role": "user",
"content": "What can you do?"
}
],
"model": "agent-pod",
"stream": False
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{role: 'user', content: 'What can you do?'}],
model: 'agent-pod',
stream: false
})
};
fetch('https://compute.x402layer.cc/pods/{id}/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://compute.x402layer.cc/pods/{id}/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([
'messages' => [
[
'role' => 'user',
'content' => 'What can you do?'
]
],
'model' => 'agent-pod',
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://compute.x402layer.cc/pods/{id}/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What can you do?\"\n }\n ],\n \"model\": \"agent-pod\",\n \"stream\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://compute.x402layer.cc/pods/{id}/v1/chat/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What can you do?\"\n }\n ],\n \"model\": \"agent-pod\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://compute.x402layer.cc/pods/{id}/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What can you do?\"\n }\n ],\n \"model\": \"agent-pod\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl_sgl_...",
"object": "chat.completion",
"created": 123,
"model": "agent-pod",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>"
},
"finish_reason": "stop"
}
],
"usage": null
}Agent Pods
Create chat completion (pod OpenAI adapter)
Runs ONE agent turn on your pod and returns an OpenAI chat.completion. Non-streaming only: stream:true is rejected with 400 stream_unsupported. usage is always null (token counts are not faked in v1). Point any OpenAI SDK at https://compute.x402layer.cc/pods/{id}/v1 with model="agent-pod". Authenticate with a pod integration key as a bearer token: Authorization: Bearer sk-sglpod-int-<key>.
POST
/
pods
/
{id}
/
v1
/
chat
/
completions
Create chat completion (pod OpenAI adapter)
curl --request POST \
--url https://compute.x402layer.cc/pods/{id}/v1/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "user",
"content": "What can you do?"
}
],
"model": "agent-pod",
"stream": false
}
'import requests
url = "https://compute.x402layer.cc/pods/{id}/v1/chat/completions"
payload = {
"messages": [
{
"role": "user",
"content": "What can you do?"
}
],
"model": "agent-pod",
"stream": False
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{role: 'user', content: 'What can you do?'}],
model: 'agent-pod',
stream: false
})
};
fetch('https://compute.x402layer.cc/pods/{id}/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://compute.x402layer.cc/pods/{id}/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([
'messages' => [
[
'role' => 'user',
'content' => 'What can you do?'
]
],
'model' => 'agent-pod',
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://compute.x402layer.cc/pods/{id}/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What can you do?\"\n }\n ],\n \"model\": \"agent-pod\",\n \"stream\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://compute.x402layer.cc/pods/{id}/v1/chat/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What can you do?\"\n }\n ],\n \"model\": \"agent-pod\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://compute.x402layer.cc/pods/{id}/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What can you do?\"\n }\n ],\n \"model\": \"agent-pod\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl_sgl_...",
"object": "chat.completion",
"created": 123,
"model": "agent-pod",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>"
},
"finish_reason": "stop"
}
],
"usage": null
}Headers
Pod integration key as a bearer token.
Example:
"Bearer sk-sglpod-int-..."
Path Parameters
Body
application/json
Was this page helpful?
