Skip to main content
POST
使用 x-api-key: $PIPELLM_API_KEY 和 anthropic-version: 2023-06-01。原生 /v1/messages 只会路由到 Anthropic 兼容平台。
string
必填
Anthropic 模型 ID,从 GET /v1/models 选取。
array
必填
对话消息。role 为 user 或 assistant。
integer
必填
最大输出 token 数。
string | array
系统提示。
number
采样温度,0–1。
number
核采样。
integer
Top-k 采样。
boolean
为 true 时返回 SSE。
string[]
自定义停止序列。
array
工具定义。见 Tool Use。

Endpoint

这条 free route 只接受 Anthropic Messages 格式请求,并只路由到 Anthropic 兼容平台。如果你想保留 Anthropic 格式去调用 OpenAI 或 Gemini 模型,请使用 Anthropic Format Converter。

安装 SDK

代码示例

响应格式

string
消息 ID。
string
固定为 message。
string
固定为 assistant。
array
输出块。文本回复是 { "type": "text", "text": "..." }。工具调用是 tool_use 块。
string
end_turn、max_tokens 或 tool_use。
object
input_tokens 和 output_tokens。

错误

错误信封与 错误 相同。原生 /v1/messages 在请求体不是 Anthropic 格式时也会返回 400。
缺少 model、messages 或 max_tokens,或协议不匹配。
缺少或无效的 x-api-key。
见 速率限制。

相关文档

路由与协议

查看原生路由约束和 converter 路由

Anthropic 概述

查看 Header、模型和路由族说明

Anthropic Format Converter

保留 Anthropic 格式,调用其他协议族模型