Anthropic Compatible

The standard Anthropic Messages compatible path, suited to the Anthropic SDK and existing Anthropic code migration.

POST/api/v1/messages

Anthropic 兼容

标准 Anthropic Messages 兼容路径;历史路径 /api/anthropic/v1/messages 继续兼容。

Bearer API KeyUse the Authorization: Bearer sk_live_... header; x-api-key is also supported.
Confirm the model call name firstFirst filter models that support this endpoint format on the Models page, then open a model detail page to copy its call name. Your account's final availability also depends on organization permissions.

Request structure

The section below confirms the method, URL and authentication scheme. It is an HTTP structure snippet, not a standalone runnable example.

HTTP
POST https://www.silvamux.com/api/v1/messages
Authorization: Bearer $SILVAMUX_API_KEY
Content-Type: application/json

Request body

application/json · AnthropicRequest · Required

FieldTypeRequiredDescription
max_tokensintegerYes单次响应允许生成的最大 token 数。
messagesarray<AnthropicMessage>Yes对话消息列表(按时间顺序)。
messages.contentstring | array<AnthropicContentBlock>Yes消息内容:字符串或内容块数组。
messages.rolestring (user | assistant)Yes消息角色(system 是顶层参数,不是消息角色)。
metadataobjectNo请求元数据。
metadata.user_idstringNo终端用户标识符。
modelstringYesSilvaMux 模型调用名(id 或 alias)。从模型广场模型详情页复制。
stop_sequencesarray<string>No停止序列列表。
streambooleanNo是否启用流式输出(SSE)。;Default: false
systemstring | array<AnthropicTextBlock>No系统提示(顶层参数)。
temperaturenumberNo采样温度,控制输出随机性。
tool_choiceAnthropicToolChoiceNo—
tool_choice.namestringNotype=tool 时指定的工具名。
tool_choice.typestring (auto | any | tool)Yesauto 模型自行决定;any 必须调用其中之一;tool 指定工具。
toolsarray<AnthropicTool>No可用工具列表。
tools.descriptionstringNo工具用途描述。
tools.input_schemaobjectYes入参的 JSON Schema。
tools.namestringYes工具名。
top_kintegerNo仅从概率前 k 的候选中采样。
top_pnumberNo核采样参数,temperature 的替代方案。

Response

200Anthropic Messages JSON 或 SSE 响应。

application/json · AnthropicMessageResponse

FieldTypeDescription
contentarray<AnthropicTextBlock | AnthropicToolUseBlock>响应内容块列表。
idstring消息 ID。
modelstring实际使用的模型名。
rolestring (assistant)—
stop_reasonstring (end_turn | max_tokens | stop_sequence | tool_use)结束原因。
stop_sequencestring命中的停止序列。
typestring (message)—
usageobject—
usage.input_tokensinteger输入 token 数。
usage.output_tokensinteger输出 token 数。

defaultAnthropic 兼容错误。

application/json · AnthropicError

FieldTypeDescription
errorobject—
error.messagestring—
error.typestring—
typestring (error)—
The historical path /api/anthropic/v1/messages remains supported for existing projects only; new projects should use /api/v1/messages.

Examples

curl https://www.silvamux.com/api/v1/messages \
  -H "Authorization: Bearer $SILVAMUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax-m2.5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Response (Anthropic format):

{
  "id": "msg_xxxx",
  "type": "message",
  "role": "assistant",
  "content": [{"type": "text", "text": "Hello! How can I help you today?"}],
  "usage": {"input_tokens": 10, "output_tokens": 15}
}

Streaming follows the Anthropic SSE specification.