12. Anthropic Messages Compatibility Endpoint#
POST /v1/messages — on top of the OpenAI-compatible pipeline, this additionally provides Anthropic Messages API protocol compatibility, drivable by the official Anthropic clients / SDKs, regardless of whether the underlying channel is actually OpenAI or Anthropic. Both non-streaming and streaming are supported (streaming is a server-synthesized Anthropic SSE event sequence).
Authentication notes#
Like every other endpoint, this one authenticates with Authorization: Bearer sk-... and does not accept Anthropic's default x-api-key header. When using the official Anthropic SDK, pass the key as a Bearer header (for example via the SDK's auth_token parameter or a custom request header) instead of the default api_key (which sends x-api-key).
Supported capabilities#
- Supported: plain-text
messages,systemprompts,max_tokens,stream, and other basic fields. - Not supported:
tools/tool_choice(function calling) and non-text content blocks (images and other multimodal content). Requests containing these fields return400immediately with an Anthropic-shaped error body — they are not silently dropped. - All errors (auth, permissions, parameters) are uniformly returned in the Anthropic error shape.
curl http://183.240.79.21:52099/v1/messages \
-H "Authorization: Bearer sk-你的YiTuoToken-Key" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 256,
"system": "你是一个简洁的助手。",
"messages": [
{ "role": "user", "content": "用一句话介绍你自己" }
]
}'
For function calling / multimodal and other advanced capabilities, use
/v1/chat/completions(OpenAI format) instead.