Messages API
Anthropic 네이티브 프로토콜을 통해 Claude와 대화할 수 있습니다. OfoxAI는 Anthropic Messages API와 완벽하게 호환되므로 공식 SDK를 그대로 사용할 수 있습니다.
엔드포인트
POST https://api.ofox.ai/anthropic/v1/messages인증
Anthropic 프로토콜은 x-api-key Header를 사용합니다:
x-api-key: <OFOXAI_API_KEY>
anthropic-version: 2023-06-01요청 파라미터
Message 형식
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 }요청 예시
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": "당신은 전문 프로그래밍 도우미입니다.",
"messages": [
{"role": "user", "content": "Python으로 퀵 정렬을 구현해 주세요"}
]
}'응답 형식
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "다음은 Python 퀵 정렬 구현입니다..."
}
],
"model": "anthropic/claude-sonnet-5.5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 200
}
}스트리밍 응답
Python
anthropic_stream.py
with client.messages.stream(
model="anthropic/claude-sonnet-5.5",
max_tokens=1024,
messages=[{"role": "user", "content": "이야기 하나 들려주세요"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)지원 모델
OfoxAI의 Anthropic 프로토콜은 Vision, Tool Use, Prompt Caching, Extended Thinking 등 모든 네이티브 기능을 지원합니다.
마지막 업데이트