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
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-5.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-5.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-5.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
OfoxAI’s Anthropic protocol supports all native features, including Vision, Tool Use, Prompt Caching, Extended Thinking, and more.
Last updated on