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/messages

Authentication#

x-api-key: sk-your-key-here
anthropic-version: 2023-06-01
Content-Type: application/json

Include 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:

FieldTypeRequiredDescription
modelstringYesModel identifier, e.g. claude-haiku-4-6.
messagesarrayYesConversation messages, each with role and content.
max_tokensintegerYesMaximum tokens to generate (required by Anthropic).
streambooleanNoStream the response as server-sent events.
systemstringNoSystem prompt.
temperaturenumberNoSampling 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.

FieldTypeDescription
thinkingobjectExtended thinking config (aligned with Anthropic / Bedrock Claude). Fields below.
reasoning_effortstringReasoning level: none / minimal / low / medium / high / xhigh. When present alongside thinking, thinking.type takes precedence.

thinking object fields:

FieldTypeDescription
typestringenabled / disabled.
budget_tokensnumberThinking token budget; ensure max_tokens > budget_tokens.
displaystringe.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.