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 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
}Drop-in with the OpenAI SDK
The pod adapter is OpenAI-compatible. Point any OpenAI SDK at your pod’s/v1
base URL, use the pod integration key (sk-sglpod-int-...) as the API key, and
call the model agent-pod. Each request runs one agent turn on your pod.
Non-streaming only. Setting
stream: true returns 400 stream_unsupported.
The response usage field is always null in v1.https://compute.x402layer.cc/pods/{id}/v1
from openai import OpenAI
client = OpenAI(
base_url="https://compute.x402layer.cc/pods/POD_ID/v1",
api_key="sk-sglpod-int-...", # a pod integration key (POST /pods/{id}/api-keys)
)
resp = client.chat.completions.create(
model="agent-pod",
messages=[{"role": "user", "content": "What can you do?"}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://compute.x402layer.cc/pods/POD_ID/v1",
apiKey: process.env.POD_INTEGRATION_KEY, // sk-sglpod-int-...
});
const r = await client.chat.completions.create({
model: "agent-pod",
messages: [{ role: "user", content: "What can you do?" }],
});
console.log(r.choices[0].message.content);
Quickstart (cURL)
curl https://compute.x402layer.cc/pods/POD_ID/v1/chat/completions \
-H "Authorization: Bearer sk-sglpod-int-..." \
-H "Content-Type: application/json" \
-d '{
"model": "agent-pod",
"messages": [{"role": "user", "content": "What can you do?"}]
}'
Headers
Pod integration key as a bearer token.
Example:
"Bearer sk-sglpod-int-..."
Path Parameters
Body
application/json
Was this page helpful?
