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요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
model | string | ✅ | 모델 식별자, 예: anthropic/claude-sonnet-4.5 |
max_tokens | number | ✅ | 최대 생성 토큰 수 |
messages | array | ✅ | 메시지 배열 |
system | string | — | 시스템 프롬프트 |
temperature | number | — | 샘플링 온도 0-1 |
top_p | number | — | 핵 샘플링 파라미터 |
top_k | number | — | Top-K 샘플링 |
stream | boolean | — | 스트리밍 응답 활성화 여부 |
tools | array | — | 도구 정의 |
tool_choice | object | — | 도구 선택 전략 |
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-4.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-4.5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 200
}
}스트리밍 응답
Python
anthropic_stream.py
with client.messages.stream(
model="anthropic/claude-sonnet-4.5",
max_tokens=1024,
messages=[{"role": "user", "content": "이야기 하나 들려주세요"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)지원 모델
| 모델 | 설명 |
|---|---|
anthropic/claude-opus-4.6 | Claude Opus 4 — 최고 성능 |
anthropic/claude-sonnet-4.5 | Claude Sonnet 4 — 균형 잡힌 성능 |
anthropic/claude-haiku-4.5 | Claude Haiku 4.5 — 빠른 응답 |
OfoxAI의 Anthropic 프로토콜은 Vision, Tool Use, Prompt Caching, Extended Thinking 등 모든 네이티브 기능을 지원합니다.
Last updated on