General chat endpoint
curl --request POST \
--url https://api.httpayer.com/llm/chat \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "Hello, how are you?"
}
],
"temperature": 0.7
}
'import requests
url = "https://api.httpayer.com/llm/chat"
payload = {
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "Hello, how are you?"
}
],
"temperature": 0.7
}
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({
messages: [
{role: 'system', content: 'You are a helpful assistant'},
{role: 'user', content: 'Hello, how are you?'}
],
temperature: 0.7
})
};
fetch('https://api.httpayer.com/llm/chat', 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.httpayer.com/llm/chat",
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' => 'system',
'content' => 'You are a helpful assistant'
],
[
'role' => 'user',
'content' => 'Hello, how are you?'
]
],
'temperature' => 0.7
]),
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.httpayer.com/llm/chat"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you?\"\n }\n ],\n \"temperature\": 0.7\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.httpayer.com/llm/chat")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you?\"\n }\n ],\n \"temperature\": 0.7\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.httpayer.com/llm/chat")
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 \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you?\"\n }\n ],\n \"temperature\": 0.7\n}"
response = http.request(request)
puts response.read_body{
"response": "I'm doing well, thank you for asking! How can I help you today?",
"model": "gpt-4o-mini-2024-07-18"
}{
"error": "Messages field is required and must be an array"
}{
"x402Version": 1,
"error": "Payment Required",
"accepts": [
{
"scheme": "exact",
"network": "base",
"payTo": "<string>",
"asset": "<string>",
"maxAmountRequired": "<string>"
}
]
}{
"error": "Chat request failed",
"message": "<string>"
}LLM
General chat endpoint
Send messages to OpenAI and receive AI responses.
Note: The AI model is configured server-side and cannot be specified in the request.
The max_tokens parameter is capped to the server-configured limit.
x402 Payment Required: This endpoint requires payment via the x402 protocol (version 1).
- First request: Returns 402 with payment requirements in
x-paymentheader - Second request: Include
X-Paymentheader with signed payment authorization
POST
/
llm
/
chat
General chat endpoint
curl --request POST \
--url https://api.httpayer.com/llm/chat \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "Hello, how are you?"
}
],
"temperature": 0.7
}
'import requests
url = "https://api.httpayer.com/llm/chat"
payload = {
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "Hello, how are you?"
}
],
"temperature": 0.7
}
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({
messages: [
{role: 'system', content: 'You are a helpful assistant'},
{role: 'user', content: 'Hello, how are you?'}
],
temperature: 0.7
})
};
fetch('https://api.httpayer.com/llm/chat', 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.httpayer.com/llm/chat",
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' => 'system',
'content' => 'You are a helpful assistant'
],
[
'role' => 'user',
'content' => 'Hello, how are you?'
]
],
'temperature' => 0.7
]),
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.httpayer.com/llm/chat"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you?\"\n }\n ],\n \"temperature\": 0.7\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.httpayer.com/llm/chat")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you?\"\n }\n ],\n \"temperature\": 0.7\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.httpayer.com/llm/chat")
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 \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you?\"\n }\n ],\n \"temperature\": 0.7\n}"
response = http.request(request)
puts response.read_body{
"response": "I'm doing well, thank you for asking! How can I help you today?",
"model": "gpt-4o-mini-2024-07-18"
}{
"error": "Messages field is required and must be an array"
}{
"x402Version": 1,
"error": "Payment Required",
"accepts": [
{
"scheme": "exact",
"network": "base",
"payTo": "<string>",
"asset": "<string>",
"maxAmountRequired": "<string>"
}
]
}{
"error": "Chat request failed",
"message": "<string>"
}Headers
x402 v1 payment authorization header (base64-encoded JSON). Include on second request after receiving 402.
Body
application/json
āI

