Messages
The Messages API accepts Claude-compatible request bodies. Its messages array and max_tokens field support Claude-compatible clients with a configurable Base URL.
API Path
| Methodology | Path | Returns by |
|---|---|---|
POST | /v1/messages | synchronous JSON or SSE streaming returned. |
Example request
bash
curl https://moonnexai.com/v1/messages \
-H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "moonnexai-claude",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "总结这个 API 的用途。"
}
]
}'Common field
| field | Annotations |
|---|---|
model | Claude compatible model name. |
messages | Dialogue message arrays. |
max_tokens | Output token cap. |
temperature | Output random. |
stream | Whether to use streaming to return. |
response Processing
| scene | Treatment |
|---|---|
| Normal Return | Reads the message content and saves the model name and request parameters. |
| streaming returns | Collapse output in an incremental format supported by the client. |
| Client Error Reporting | Priority check for Base URL, model name, authentication and max_tokens. |
Access Recommendations
- Select this API first when Claude is already used.
- If the client only supports OpenAI Chat format, change to Chat Completions.
- Check Base URL, model name and API Key permissions when request fails.