# Claude Opus 4.7 API Referensi API lengkap untuk model model bahasa besar Claude Opus 4.7 yang didukung oleh Anthropic. ## Varian Model API ini mendukung dua varian model Claude Opus 4.7: | Model | ID | Deskripsi | |-------|----|-------------| | **Claude Opus 4.7 Text to Text** | `claude-opus-4.7-text-to-text` | model bahasa besar teks dan penalaran Claude Opus terbaru | | **Claude Opus 4.7 File Analysis** | `claude-opus-4.7-file-analysis` | Analisis file dan gambar Claude Opus terbaru | ## Perbandingan Cepat | Fitur | Text to Text | File Analysis | |---------|--------------|---------------| | Input teks | Wajib ✅ | Opsional | | Input gambar | Tidak didukung ❌ | Opsional | | Input file | Tidak didukung ❌ | Opsional | | Respons streaming | SSE | SSE | | `max_tokens` | Opsional | Opsional | | `top_p` | Opsional | Opsional | | `top_k` | Opsional | Opsional | ## Claude Opus 4.7 Text to Text ### Endpoint ```http POST /api/v1/chat/completions ``` ### Parameter Permintaan #### Wajib | Parameter | Tipe | Deskripsi | |-----------|------|-------------| | `model` | string | Harus berupa `"claude-opus-4.7-text-to-text"` | | `messages` | array | Pesan berurutan. Lihat model bahasa besar API untuk struktur pesan. | | `stream` | boolean | `true` untuk SSE, `false` untuk satu respons JSON. | #### Dukungan Pesan | Field | Teks | File | Gambar | |-------|------|------|-------| | `messages` | Wajib ✅ | Tidak didukung ❌ | Tidak didukung ❌ | #### Opsional | Parameter | Tipe | Rentang | Deskripsi | |-----------|------|-------|-------------| | `max_tokens` | integer | `1` - `64000` | Token output maksimum. | | `top_p` | number | `0.0` - `1.0` | Membatasi massa probabilitas kumulatif untuk kandidat token. | | `top_k` | integer | `> 0` | Membatasi jumlah kandidat token. | ### Contoh Permintaan ```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 ### Endpoint ```http POST /api/v1/chat/completions ``` ### Parameter Permintaan #### Wajib | Parameter | Tipe | Deskripsi | |-----------|------|-------------| | `model` | string | Harus berupa `"claude-opus-4.7-file-analysis"` | | `messages` | array | Pesan berurutan. Lihat model bahasa besar API dan model bahasa besar Attachments. | | `stream` | boolean | `true` untuk SSE, `false` untuk satu respons JSON. | #### Dukungan Pesan | Field | Teks | File | Gambar | |-------|------|------|-------| | `messages` | Opsional | Opsional | Opsional | #### Opsional | Parameter | Tipe | Rentang | Deskripsi | |-----------|------|-------|-------------| | `max_tokens` | integer | `1` - `64000` | Token output maksimum. | | `top_p` | number | `0.0` - `1.0` | Membatasi massa probabilitas kumulatif untuk kandidat token. | | `top_k` | integer | `> 0` | Membatasi jumlah kandidat token. | ### Contoh Permintaan ```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 }) }); ``` ## Format Respons Model LLM Claude Opus 4.7 mengembalikan respons completion yang kompatibel dengan OpenAI. Dengan `stream: true`, respons berupa Server-Sent Events; dengan `stream: false`, respons berupa satu objek JSON. ### Respons Berhasil ```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] ``` ### Respons Error ```text event: error data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}} ``` ## Praktik Terbaik 1. **Gunakan pesan terstruktur:** Kirim riwayat percakapan melalui `messages[]` alih-alih meratakan konteks menjadi satu prompt. 2. **Pilih varian model yang tepat:** Gunakan Text to Text untuk reasoning dan penulisan teks saja, dan File Analysis saat file atau gambar diperlukan. 3. **Sesuaikan parameter Claude dengan hati-hati:** `top_p` dan `top_k` didukung dan dapat mengubah keragaman output. 4. **Konsumsi event SSE:** Tambahkan `choices[0].delta.content` untuk tampilan streaming dan gunakan `data: [DONE]` sebagai respons final. 5. **Kirim hanya input yang didukung:** Model Text mengabaikan bagian file dan gambar yang tidak didukung di client saat ini.