Create a message (Anthropic)
curl --request POST \
--url https://grid.x402compute.cc/v1/messages \
--header 'Content-Type: application/json' \
--data '
{
"model": "qwen-2.5-32b",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"system": "<string>",
"stream": false,
"temperature": 123,
"stop_sequences": [
"<string>"
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": {},
"thinking": {},
"metadata": {}
}
'import requests
url = "https://grid.x402compute.cc/v1/messages"
payload = {
"model": "qwen-2.5-32b",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"system": "<string>",
"stream": False,
"temperature": 123,
"stop_sequences": ["<string>"],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": {},
"thinking": {},
"metadata": {}
}
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: 'qwen-2.5-32b',
max_tokens: 512,
messages: [{role: 'user', content: 'Hello'}],
system: '<string>',
stream: false,
temperature: 123,
stop_sequences: ['<string>'],
tools: [{name: '<string>', description: '<string>', input_schema: {}}],
tool_choice: {},
thinking: {},
metadata: {}
})
};
fetch('https://grid.x402compute.cc/v1/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://grid.x402compute.cc/v1/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' => 'qwen-2.5-32b',
'max_tokens' => 512,
'messages' => [
[
'role' => 'user',
'content' => 'Hello'
]
],
'system' => '<string>',
'stream' => false,
'temperature' => 123,
'stop_sequences' => [
'<string>'
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'input_schema' => [
]
]
],
'tool_choice' => [
],
'thinking' => [
],
'metadata' => [
]
]),
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://grid.x402compute.cc/v1/messages"
payload := strings.NewReader("{\n \"model\": \"qwen-2.5-32b\",\n \"max_tokens\": 512,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ],\n \"system\": \"<string>\",\n \"stream\": false,\n \"temperature\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {}\n }\n ],\n \"tool_choice\": {},\n \"thinking\": {},\n \"metadata\": {}\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://grid.x402compute.cc/v1/messages")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"qwen-2.5-32b\",\n \"max_tokens\": 512,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ],\n \"system\": \"<string>\",\n \"stream\": false,\n \"temperature\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {}\n }\n ],\n \"tool_choice\": {},\n \"thinking\": {},\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://grid.x402compute.cc/v1/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\": \"qwen-2.5-32b\",\n \"max_tokens\": 512,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ],\n \"system\": \"<string>\",\n \"stream\": false,\n \"temperature\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {}\n }\n ],\n \"tool_choice\": {},\n \"thinking\": {},\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "message",
"role": "assistant",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>",
"source": {},
"id": "<string>",
"name": "<string>",
"input": {},
"tool_use_id": "<string>",
"content": "<string>",
"is_error": true
}
],
"stop_reason": "end_turn",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cost_usd": 123
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}SGL Grid
Create a message (Anthropic)
Anthropic Messages API on Grid models. Works with the official Anthropic SDKs and Claude Code by setting the base URL to https://grid.x402compute.cc. Same auth, x402 payment, routing and billing as /v1/chat/completions. ?beta=true is accepted. Unsupported features (extended thinking with a budget, structured outputs, server tools, documents, image URLs, top_p, top_k, prefill, unknown fields) return 400 invalid_request_error. See the Anthropic API guide.
POST
/
v1
/
messages
Create a message (Anthropic)
curl --request POST \
--url https://grid.x402compute.cc/v1/messages \
--header 'Content-Type: application/json' \
--data '
{
"model": "qwen-2.5-32b",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"system": "<string>",
"stream": false,
"temperature": 123,
"stop_sequences": [
"<string>"
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": {},
"thinking": {},
"metadata": {}
}
'import requests
url = "https://grid.x402compute.cc/v1/messages"
payload = {
"model": "qwen-2.5-32b",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"system": "<string>",
"stream": False,
"temperature": 123,
"stop_sequences": ["<string>"],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": {},
"thinking": {},
"metadata": {}
}
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: 'qwen-2.5-32b',
max_tokens: 512,
messages: [{role: 'user', content: 'Hello'}],
system: '<string>',
stream: false,
temperature: 123,
stop_sequences: ['<string>'],
tools: [{name: '<string>', description: '<string>', input_schema: {}}],
tool_choice: {},
thinking: {},
metadata: {}
})
};
fetch('https://grid.x402compute.cc/v1/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://grid.x402compute.cc/v1/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' => 'qwen-2.5-32b',
'max_tokens' => 512,
'messages' => [
[
'role' => 'user',
'content' => 'Hello'
]
],
'system' => '<string>',
'stream' => false,
'temperature' => 123,
'stop_sequences' => [
'<string>'
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'input_schema' => [
]
]
],
'tool_choice' => [
],
'thinking' => [
],
'metadata' => [
]
]),
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://grid.x402compute.cc/v1/messages"
payload := strings.NewReader("{\n \"model\": \"qwen-2.5-32b\",\n \"max_tokens\": 512,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ],\n \"system\": \"<string>\",\n \"stream\": false,\n \"temperature\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {}\n }\n ],\n \"tool_choice\": {},\n \"thinking\": {},\n \"metadata\": {}\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://grid.x402compute.cc/v1/messages")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"qwen-2.5-32b\",\n \"max_tokens\": 512,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ],\n \"system\": \"<string>\",\n \"stream\": false,\n \"temperature\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {}\n }\n ],\n \"tool_choice\": {},\n \"thinking\": {},\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://grid.x402compute.cc/v1/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\": \"qwen-2.5-32b\",\n \"max_tokens\": 512,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ],\n \"system\": \"<string>\",\n \"stream\": false,\n \"temperature\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {}\n }\n ],\n \"tool_choice\": {},\n \"thinking\": {},\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "message",
"role": "assistant",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>",
"source": {},
"id": "<string>",
"name": "<string>",
"input": {},
"tool_use_id": "<string>",
"content": "<string>",
"is_error": true
}
],
"stop_reason": "end_turn",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cost_usd": 123
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>"
},
"request_id": "<string>"
}Headers
Body
application/json
Response
The message, or an SSE stream when stream is true.
Was this page helpful?
