跳转到主要内容
curl https://api.poixe.com/v1/messages \
  -H "Content-Type: application/json" \
    -H 'Content-Type: application/json' \
    -H 'anthropic-version: 2023-06-01' \
    -H "X-Api-Key: $POIXE_API_KEY" \
    -d '{
          "max_tokens": 1024,
          "messages": [
            {
              "role": "user",
              "content": "Hello!"
            }
          ],
          "model": "claude-sonnet-4-5-20250929",
          "stream": false
        }'
{
  "model": "claude-sonnet-4-5-20250929",
  "id": "msg_019SV1gQjKXteTibBnxT9rN3",
  "type": "message",
  "role": "assistant",
  "content": [{ "type": "text", "text": "Hello! How can I help you today?" }],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 9,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    },
    "output_tokens": 12,
    "service_tier": "standard"
  }
}
POST https://api.poixe.com/v1/messages
这是 Claude(Anthropic)最核心的对话协议,支持文本、多模态、工具调用与 SSE 流式输出。 系统在该路径下对齐 Anthropic 的字段与事件流格式,便于直接复用现有 Claude SDK 或请求结构。

鉴权与请求头

所有请求都需要携带 API Key,同时建议固定携带 anthropic-version 以保证行为稳定。
X-Api-Key
string
必填
Poixe API Key。格式为 X-Api-Key: YOUR_API_KEY(等价于 x-api-key)。
anthropic-version
string
必填
Anthropic 版本号,例如:2023-06-01
Content-Type
string
必填
必须设置为 application/json

核心请求参数

以下为最常用、最通用的一组字段(足够覆盖:普通对话 + 工具调用 + 流式)。
model
string
必填
模型 ID,例如:claude-sonnet-4-5-20250929
messages
object[]
必填
对话消息列表。
max_tokens
integer
必填
本次生成允许的最大输出 Token 数。
stream
boolean
默认值:"false"
是否开启 SSE 流式输出。为 true 时返回 text/event-stream
temperature
number
可选:采样温度。越低越稳定,越高越发散(不传则使用模型默认值)。
system
string
可选:系统提示词(用于设定助手整体行为)。
tools
object[]
可选:工具列表(函数/工具调用)。
tool_choice
object
可选:工具调用策略,例如 {"type":"any"}(允许调用任意工具)。

响应结构与流式事件

非流式时,返回一个 message 对象;流式时,返回一系列 SSE 事件(message_start → content block events → message_deltamessage_stop),其中可能穿插 ping
id
string
消息 ID,例如 msg_xxx
type
string
固定为 message
role
string
固定为 assistant
content
object[]
生成内容数组,常见为 [{ "type": "text", "text": "..." }]
stop_reason
string
停止原因,常见:end_turn / max_tokens / stop_sequence / tool_use(以及少数情况:pause_turn / refusal / model_context_window_exceeded 等)。
stop_sequence
string | null
命中 stop 序列时返回对应字符串,否则为 null
usage
object
Token 用量统计。