Skip to Content
API 레퍼런스Anthropic 네이티브 프로토콜Messages

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

요청 파라미터

파라미터타입필수설명
modelstring모델 식별자, 예: anthropic/claude-sonnet-4.5
max_tokensnumber최대 생성 토큰 수
messagesarray메시지 배열
systemstring시스템 프롬프트
temperaturenumber샘플링 온도 0-1
top_pnumber핵 샘플링 파라미터
top_knumberTop-K 샘플링
streamboolean스트리밍 응답 활성화 여부
toolsarray도구 정의
tool_choiceobject도구 선택 전략

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 }

요청 예시

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 } }

스트리밍 응답

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.6Claude Opus 4 — 최고 성능
anthropic/claude-sonnet-4.5Claude Sonnet 4 — 균형 잡힌 성능
anthropic/claude-haiku-4.5Claude Haiku 4.5 — 빠른 응답

OfoxAI의 Anthropic 프로토콜은 Vision, Tool Use, Prompt Caching, Extended Thinking 등 모든 네이티브 기능을 지원합니다.

Last updated on