Skip to Content

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

Authentication

The Anthropic protocol uses the x-api-key header:

x-api-key: <your OFOXAI_API_KEY> anthropic-version: 2023-06-01

Request Parameters

ParameterTypeRequiredDescription
modelstringModel identifier, e.g. anthropic/claude-sonnet-4.5
max_tokensnumberMaximum tokens to generate
messagesarrayMessage array
systemstringSystem prompt
temperaturenumberSampling temperature 0-1
top_pnumberNucleus sampling parameter
top_knumberTop-K sampling
streambooleanEnable streaming response
toolsarrayTool definitions
tool_choiceobjectTool 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

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

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

ModelDescription
anthropic/claude-opus-4.6Claude Opus 4 — Most capable
anthropic/claude-sonnet-4.5Claude Sonnet 4 — Balanced performance
anthropic/claude-haiku-4.5Claude 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