curl -X POST https://api-llm.sunra.ai/v1/messages \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/messages",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/messages", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4-6",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, how are you?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
}
],
"model": "anthropic/claude-sonnet-4-6",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 19,
"total_tokens": 31,
"sunra_usage_semantics": "anthropic.exclusive.v1"
}
}
LLM
Create a message
POST
/
v1
/
messages
curl -X POST https://api-llm.sunra.ai/v1/messages \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/messages",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/messages", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4-6",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, how are you?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
}
],
"model": "anthropic/claude-sonnet-4-6",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 19,
"total_tokens": 31,
"sunra_usage_semantics": "anthropic.exclusive.v1"
}
}
使用 Anthropic Messages API 格式创建消息。支持文本、图像、PDF、工具和扩展思维。
认证
请求
此端点接受一个 JSON 对象。将完成您的提示的模型。在 sunra.ai/models 浏览可用模型。
可选的 Provider 路由偏好。省略时使用自动路由。支持的字段和 Provider 查询方式见 Provider 路由。
输入消息。每条输入消息都有一个
role 和 content。显示 属性
显示 属性
停止前生成的最大令牌数。请注意,模型可能会在达到此最大值之前停止。不同模型的上限不同;超过模型自身上限的值会返回
400,而不会被静默削平。见输出上限。是否使用服务器发送事件(SSE)增量流式传输响应。流式请求受空闲超时与生命周期上限约束,见输出上限与流生命周期。非流式请求的响应若迟迟无法送达,会在边缘被终止,因此任何可能生成超过约 90 秒的请求都必须设置
stream: true——见 边缘超时。响应
成功的消息响应。模型停止的原因。可以是
end_turn(模型到达自然停止点)、max_tokens(超过 max_tokens 或模型的最大值)、stop_sequence(生成了您的自定义停止序列之一)或 tool_use(模型调用了一个或多个工具)。curl -X POST https://api-llm.sunra.ai/v1/messages \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/messages",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/messages", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4-6",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, how are you?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
}
],
"model": "anthropic/claude-sonnet-4-6",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 19,
"total_tokens": 31,
"sunra_usage_semantics": "anthropic.exclusive.v1"
}
}