# Claude Opus 4.7 API Anthropic 기반 Claude Opus 4.7 LLM의 완전한 API 참조 문서입니다. ## 모델 변형 이 API는 두 가지 Claude Opus 4.7 모델 변형을 지원합니다: | 모델 | ID | 설명 | |-------|----|-------------| | **Claude Opus 4.7 Text to Text** | `claude-opus-4.7-text-to-text` | 최신 Claude Opus 텍스트 LLM 및 추론 | | **Claude Opus 4.7 File Analysis** | `claude-opus-4.7-file-analysis` | 최신 Claude Opus 파일 및 이미지 분석 | ## 빠른 비교 | 기능 | Text to Text | File Analysis | |---------|--------------|---------------| | 텍스트 입력 | 필수 ✅ | 선택 사항 | | 이미지 입력 | 지원되지 않음 ❌ | 선택 사항 | | 파일 입력 | 지원되지 않음 ❌ | 선택 사항 | | 스트리밍 응답 | SSE | SSE | | `max_tokens` | 선택 사항 | 선택 사항 | | `top_p` | 선택 사항 | 선택 사항 | | `top_k` | 선택 사항 | 선택 사항 | ## Claude Opus 4.7 Text to Text ### 엔드포인트 ```http POST /api/v1/chat/completions ``` ### 요청 파라미터 #### 필수 | 파라미터 | 타입 | 설명 | |-----------|------|-------------| | `model` | string | 반드시 `"claude-opus-4.7-text-to-text"`이어야 합니다 | | `messages` | array | 순서가 있는 메시지입니다. 메시지 구조는 LLM API를 참조하세요. | | `stream` | boolean | `true`이면 SSE, `false`이면 단일 JSON 응답입니다. | #### 메시지 지원 | 필드 | 텍스트 | 파일 | 이미지 | |-------|------|------|-------| | `messages` | 필수 ✅ | 지원되지 않음 ❌ | 지원되지 않음 ❌ | #### 선택 사항 | 파라미터 | 타입 | 범위 | 설명 | |-----------|------|-------|-------------| | `max_tokens` | integer | `1` - `64000` | 최대 출력 토큰 수. | | `top_p` | number | `0.0` - `1.0` | 후보 토큰의 누적 확률 질량을 제한합니다. | | `top_k` | integer | `> 0` | 후보 토큰 수를 제한합니다. | ### 요청 예시 ```javascript 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.7-text-to-text', messages: [ { role: 'user', content: 'Draft a technical decision memo for this architecture choice.' } ], stream: true, max_tokens: 2048, top_p: 0.5, top_k: 50 }) }); ``` ## Claude Opus 4.7 File Analysis ### 엔드포인트 ```http POST /api/v1/chat/completions ``` ### 요청 파라미터 #### 필수 | 파라미터 | 타입 | 설명 | |-----------|------|-------------| | `model` | string | 반드시 `"claude-opus-4.7-file-analysis"`이어야 합니다 | | `messages` | array | 순서가 있는 메시지입니다. LLM API와 메시지 첨부를 참조하세요. | | `stream` | boolean | `true`이면 SSE, `false`이면 단일 JSON 응답입니다. | #### 메시지 지원 | 필드 | 텍스트 | 파일 | 이미지 | |-------|------|------|-------| | `messages` | 선택 사항 | 선택 사항 | 선택 사항 | #### 선택 사항 | 파라미터 | 타입 | 범위 | 설명 | |-----------|------|-------|-------------| | `max_tokens` | integer | `1` - `64000` | 최대 출력 토큰 수. | | `top_p` | number | `0.0` - `1.0` | 후보 토큰의 누적 확률 질량을 제한합니다. | | `top_k` | integer | `> 0` | 후보 토큰 수를 제한합니다. | ### 요청 예시 ```javascript 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.7-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, top_p: 0.5, top_k: 50 }) }); ``` ## 응답 형식 Claude Opus 4.7 LLM 모델은 OpenAI 호환 completion 응답을 반환합니다. `stream: true`이면 응답은 Server-Sent Events이고, `stream: false`이면 단일 JSON 객체입니다. ### 성공 응답 ```text data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.7-file-analysis","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.7-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.7-file-analysis","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.7-file-analysis","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}} data: [DONE] ``` ### 오류 응답 ```text event: error data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}} ``` ## 모범 사례 1. **구조화된 메시지를 사용하세요:** 컨텍스트를 하나의 프롬프트로 합치지 말고 `messages[]`를 통해 대화 기록을 보내세요. 2. **올바른 모델 변형을 선택하세요:** 텍스트 전용 LLM 모델에는 Text to Text를 사용하고, 파일이나 이미지가 필요하면 File Analysis를 사용하세요. 3. **Claude 파라미터를 신중하게 조정하세요:** `top_p`와 `top_k`가 지원되며 출력 다양성을 바꿀 수 있습니다. 4. **SSE 이벤트를 소비하세요:** 스트리밍 표시에는 `choices[0].delta.content`를 추가하고 최종 응답에는 `data: [DONE]`를 사용하세요. 5. **지원되는 입력만 보내세요:** 현재 클라이언트에서 Text 모델은 지원되지 않는 파일 및 이미지 파트를 무시합니다.