ModelSite
Chat

Messages (Anthropic-compatible)

POST /v1/messages — Anthropic Messages API

Compatible with the Anthropic Messages API. Under the hood it shares the same routing pipeline as Chat Completions — only the request/response shape is adapted to Anthropic style.

Auth difference (important): the platform's /messages uses Authorization: Bearer $MODELSITE_API_KEY, not official Anthropic x-api-key. With the official anthropic SDK pass auth_token (Bearer); do not pass api_key (sends x-api-key → 401). The anthropic-version header is required.

Example

from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.modelsite.ai",   # SDK appends /v1/messages
    auth_token="ms_live_sk_xxxxxxxx",       # Authorization: Bearer (required — not api_key)
)
resp = client.messages.create(
    model="claude-sonnet-4.6",
    max_tokens=256,
    messages=[{"role": "user", "content": "Explain quantum entanglement in one sentence"}],
)
print(resp.content[0].text)

The API card below is rendered from the OpenAPI spec (auth, Request-body parameter table, Response schema).

POST
/messages

Authorization

BearerAuth
AuthorizationBearer <token>

Authorization: Bearer $MODELSITE_API_KEY(与 OpenAI 格式共享同一 Key)

In: header

Header Parameters

anthropic-version*string

Anthropic API 版本。

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/messages" \  -H "anthropic-version: 2023-06-01" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "messages": [      {}    ],    "max_tokens": 0  }'
{  "id": "string",  "type": "string",  "role": "string",  "model": "string",  "content": [    {      "type": "string",      "text": "string"    }  ],  "stop_reason": "end_turn",  "stop_sequence": "string",  "usage": {    "input_tokens": 0,    "output_tokens": 0,    "cache_creation_input_tokens": 0,    "cache_read_input_tokens": 0  }}

Streaming

stream: true returns an event sequence: message_startcontent_block_startcontent_block_delta (many) → content_block_stopmessage_deltamessage_stop.

Which format?

Existing codeRecommended entry point
OpenAI / LangChain(OpenAI) / most frameworks/chat/completions
Anthropic SDK/messages (this page)

Both entry points reach the same set of models.

On this page