Messages (Anthropic)
The Messages endpoint is Anthropic-compatible. Use it with Claude models and any Anthropic-protocol model in the catalog.
POST https://api.smartapi.cc/api/openapi/v1/messagesAuthentication#
x-api-key: sk-your-key-here
anthropic-version: 2023-06-01
Content-Type: application/jsonInclude the anthropic-version header, as the official Anthropic SDK does.
The optional anthropic-beta header is also forwarded to the upstream
provider.
Request body#
Standard Anthropic Messages parameters are supported and forwarded unchanged. Common fields:
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier, e.g. claude-haiku-4-6. |
messages | array | Yes | Conversation messages, each with role and content. |
max_tokens | integer | Yes | Maximum tokens to generate (required by Anthropic). |
stream | boolean | No | Stream the response as server-sent events. |
system | string | No | System prompt. |
temperature | number | No | Sampling temperature. |
Thinking / Reasoning#
Whether to enable thinking/reasoning is controlled by request parameters. Models
that support thinking carry a thinking tag on the Models page.
Thinking is off by default when none of the parameters below are sent.
| Field | Type | Description |
|---|---|---|
thinking | object | Extended thinking config (aligned with Anthropic / Bedrock Claude). Fields below. |
reasoning_effort | string | Reasoning level: none / minimal / low / medium / high / xhigh. When present alongside thinking, thinking.type takes precedence. |
thinking object fields:
| Field | Type | Description |
|---|---|---|
type | string | enabled / disabled. |
budget_tokens | number | Thinking token budget; ensure max_tokens > budget_tokens. |
display | string | e.g. omitted; forwarded when the upstream supports it. |
{
"model": "claude-sonnet-4-6",
"max_tokens": 16000,
"messages": [{ "role": "user", "content": "Hello" }],
"thinking": {
"type": "enabled",
"budget_tokens": 10000,
"display": "omitted"
}
}Basic example#
curl https://api.smartapi.cc/api/openapi/v1/messages \
-H "x-api-key: $SMARTAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-haiku-4-6",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "What is SmartAPI?" }
]
}'Response#
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "claude-haiku-4-6",
"content": [{ "type": "text", "text": "SmartAPI is..." }],
"stop_reason": "end_turn",
"usage": { "input_tokens": 18, "output_tokens": 92 }
}Using the Anthropic SDK#
Point the SDK’s base URL at the SmartAPI OpenAPI root; the SDK appends
/v1/messages itself.
import anthropic
client = anthropic.Anthropic(
api_key="sk-your-key-here",
base_url="https://api.smartapi.cc/api/openapi",
)
message = client.messages.create(
model="claude-haiku-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about APIs."}],
)
print(message.content[0].text)Streaming#
Set stream to true to receive incremental text/event-stream events. Text
deltas arrive in content_block_delta events:
event: content_block_delta
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"}}Usage and billing#
The usage object reports input_tokens and output_tokens, plus
cache_read_input_tokens when prompt caching applies. Token usage drives
billing.