Claude Opus 4.8 API
Anthropic 기반 Claude Opus 4.8 LLM의 완전한 API 참조 문서입니다.
모델 변형
이 API는 두 가지 Claude Opus 4.8 모델 변형을 지원합니다:
빠른 비교
Claude Opus 4.8 Text to Text
엔드포인트 {#}
POST /api/v1/chat/completions
요청 파라미터
필수
메시지 지원
선택 사항
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'claude-opus-4.8-text-to-text',
messages: [
{
role: 'user',
content: 'Draft a technical decision memo for this architecture choice.'
}
],
stream: true,
max_tokens: 2048
})
});
Claude Opus 4.8 File Analysis
엔드포인트
POST /api/v1/chat/completions
요청 파라미터
필수
메시지 지원
선택 사항
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'claude-opus-4.8-file-analysis',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Summarize this file and extract the key risks.' },
{
type: 'file',
file: {
filename: 'demo.pdf',
file_data: 'https://example.com/demo.pdf'
}
}
]
}
],
stream: true,
max_tokens: 4096
})
});
응답 형식
Claude Opus 4.8 LLM 모델은 OpenAI 호환 completion 응답을 반환합니다. stream: true이면 응답은 Server-Sent Events이고, stream: false이면 단일 JSON 객체입니다.
성공 응답
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.8-file-analysis","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.8-file-analysis","choices":[{"index":0,"delta":{"content":"Here is a concise summary"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.8-file-analysis","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.8-file-analysis","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}
data: [DONE]
오류 응답
event: error
data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}}
모범 사례
- 구조화된 메시지를 사용하세요: 컨텍스트를 하나의 프롬프트로 합치지 말고
messages[]를 통해 대화 기록을 보내세요.
- 올바른 모델 변형을 선택하세요: 텍스트 전용 LLM 모델에는 Text to Text를 사용하고, 파일이나 이미지가 필요하면 File Analysis를 사용하세요.
- SSE 이벤트를 처리하세요: 스트리밍 표시에는
choices[0].delta.content를 추가하고 data: [DONE]을 성공적인 완료로 처리하세요.
- 지원되는 입력만 보내세요: 현재 클라이언트에서 텍스트 모델은 지원되지 않는 파일 및 이미지 파트를 무시합니다.