curl --request POST \ --url https://api.poyo.ai/v1/messages \ --header 'Content-Type: application/json' \ --header 'x-api-key: <api-key>' \ --data '{ "model": "claude-sonnet-4-5-20250929", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time." } ]}'
import requests
url = "https://api.poyo.ai/v1/messages"
payload = {
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time."
}
]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
messages: [
{
role: 'user',
content: 'Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.'
}
]
})
};
fetch('https://api.poyo.ai/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://api.poyo.ai/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' => 'claude-sonnet-4-5-20250929',
'max_tokens' => 1024,
'messages' => [
[
'role' => 'user',
'content' => 'Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.poyo.ai/v1/messages"
payload := strings.NewReader("{\n \"model\": \"claude-sonnet-4-5-20250929\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.poyo.ai/v1/messages")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"claude-sonnet-4-5-20250929\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://api.poyo.ai/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"claude-sonnet-4-5-20250929\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Claude Messages API 是与模型无关的接口,兼容 Anthropic Messages 格式。它接受单轮或多轮的文本和图像输入,页面示例展示了流式输出和工具使用。
POST
/
v1
/
messages
Claude Messages API
curl --request POST \ --url https://api.poyo.ai/v1/messages \ --header 'Content-Type: application/json' \ --header 'x-api-key: <api-key>' \ --data '{ "model": "claude-sonnet-4-5-20250929", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time." } ]}'
import requests
url = "https://api.poyo.ai/v1/messages"
payload = {
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time."
}
]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
messages: [
{
role: 'user',
content: 'Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.'
}
]
})
};
fetch('https://api.poyo.ai/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://api.poyo.ai/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' => 'claude-sonnet-4-5-20250929',
'max_tokens' => 1024,
'messages' => [
[
'role' => 'user',
'content' => 'Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.poyo.ai/v1/messages"
payload := strings.NewReader("{\n \"model\": \"claude-sonnet-4-5-20250929\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.poyo.ai/v1/messages")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"claude-sonnet-4-5-20250929\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://api.poyo.ai/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"claude-sonnet-4-5-20250929\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Rewrite the following product announcement to be more gentle and user-friendly: We will have maintenance for 2 hours this weekend, services will be unavailable during this time.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
{ "model": "claude-sonnet-4-5-20250929", "max_tokens": 256, "messages": [ {"role": "user", "content": "Explain the meaning of 'rate limiting' in three sentences."} ]}
{ "model": "claude-sonnet-4-5-20250929", "max_tokens": 256, "messages": [ { "role": "user", "content": [ {"type": "text", "text": "Describe the main subject and scene in the image, and provide an alt text for it."}, { "type": "image", "source": { "type": "base64", "media_type": "image/png", "data": "BASE64_IMAGE_DATA" } } ] } ]}
按顺序排列的对话消息列表。每条消息包含 role 和 content。user 用于用户输入,assistant 用于多轮对话中模型之前的输出。示例:[{"role": "user", "content": "Summarize the purpose of feature canary releases in two sentences."}]。