Messages API
Create Claude conversations through the Anthropic native protocol. OfoxAI is fully compatible with the Anthropic Messages API, so you can use the official SDK directly.
Endpoint
POST https://api.ofox.ai/anthropic/v1/messagesAuthentication
The Anthropic protocol uses the x-api-key header:
x-api-key: <your OFOXAI_API_KEY>
anthropic-version: 2023-06-01Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | ✅ | Model identifier, e.g. anthropic/claude-sonnet-4.5 |
max_tokens | number | ✅ | Maximum tokens to generate |
messages | array | ✅ | Message array |
system | string | — | System prompt |
temperature | number | — | Sampling temperature 0-1 |
top_p | number | — | Nucleus sampling parameter |
top_k | number | — | Top-K sampling |
stream | boolean | — | Enable streaming response |
tools | array | — | Tool definitions |
tool_choice | object | — | Tool selection strategy |
Message Format
interface Message {
role: 'user' | 'assistant'
content: string | ContentBlock[]
}
type ContentBlock =
| { type: 'text'; text: string }
| { type: 'image'; source: { type: 'base64'; media_type: string; data: string } }
| { type: 'tool_use'; id: string; name: string; input: object }
| { type: 'tool_result'; tool_use_id: string; content: string }Request Examples
cURL
Terminal
curl https://api.ofox.ai/anthropic/v1/messages \
-H "x-api-key: $OFOX_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.5",
"max_tokens": 1024,
"system": "You are a professional programming assistant.",
"messages": [
{"role": "user", "content": "Write a quicksort in Python"}
]
}'Response Format
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Here's a Python quicksort implementation..."
}
],
"model": "anthropic/claude-sonnet-4.5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 200
}
}Streaming
Python
anthropic_stream.py
with client.messages.stream(
model="anthropic/claude-sonnet-4.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Tell me a story"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Supported Models
| Model | Description |
|---|---|
anthropic/claude-opus-4.6 | Claude Opus 4 — Most capable |
anthropic/claude-sonnet-4.5 | Claude Sonnet 4 — Balanced performance |
anthropic/claude-haiku-4.5 | Claude Haiku 4.5 — Fast responses |
OfoxAI’s Anthropic protocol supports all native features, including Vision, Tool Use, Prompt Caching, Extended Thinking, and more.
Last updated on