Submit conversations using the Anthropic Messages protocol. Put system instructions at the top level, rather than using a system role inside messages.
Request
| Item | Description |
|---|---|
| Method | POST |
| Path | /v1/messages |
| Gateway URL | https://ailink.nativex.com |
| Authentication | Authorization: Bearer sk-xxxx; replace the placeholder with your API Key |
| Request format | application/json |
Replace MODEL_ID with a model from the Model Marketplace that supports this endpoint. Available models, parameters, and permissions depend on your account.
Parameters
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
anthropic-version |
Header | string | Yes | API version, such as 2023-06-01 |
model |
Body | string | Yes | A model that supports the Claude protocol |
messages |
Body | object[] | Yes | user / assistant messages; content can be text or content blocks |
max_tokens |
Body | integer | Yes | Positive integer limiting the maximum output token count |
system |
Body | string / object[] | No | System instructions |
stream |
Body | boolean | No | true enables streaming events |
temperature |
Body | number | No | Traditional range: 0–1. Check the specific model. |
tools |
Body | object[] | No | Tool definitions |
thinking |
Body | object | No | Thinking configuration; requires model support |
Supported combinations of thinking and sampling parameters vary by model. Avoid copying another model's settings without checking compatibility.
Example
curl -X POST 'https://ailink.nativex.com/v1/messages' \
-H 'Authorization: Bearer sk-xxxx' \
-H 'anthropic-version: 2023-06-01' \
-H 'Content-Type: application/json' \
-d '{
"model": "MODEL_ID",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Introduce yourself in one sentence."
}
]
}'
Response
The following is a simplified response for readability. IDs, URLs, text, and usage values are illustrative.
{
"id": "msg_example",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "I am your AI assistant."
}
],
"stop_reason": "end_turn"
}
| Field or result | Description |
|---|---|
| content[] | Output blocks such as text and tool calls |
| stop_reason | Reason generation stopped |
| usage | Input and output usage |
Error handling
For unsuccessful responses, check the HTTP status and error body first. Verify the API Key, model name, account balance, and parameters. If rate limited, reduce concurrency and retry later.