Claude Opus 4.6 API
Referensi API lengkap untuk model model bahasa besar Claude Opus 4.6 yang didukung oleh Anthropic.
Varian Model
API ini mendukung dua varian model Claude Opus 4.6:
Perbandingan Cepat
Claude Opus 4.6 Text to Text
Endpoint
POST /api/v1/chat/completions
Parameter Permintaan
Wajib
Dukungan Pesan
Opsional
Contoh Permintaan
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.6-text-to-text',
messages: [
{
role: 'user',
content: 'Analyze this launch strategy and list the biggest risks.'
}
],
stream: true,
max_tokens: 2048,
top_p: 0.5,
top_k: 50
})
});
Claude Opus 4.6 File Analysis
Endpoint
POST /api/v1/chat/completions
Parameter Permintaan
Wajib
Dukungan Pesan
Opsional
Contoh Permintaan
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.6-file-analysis',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Review this document and identify missing requirements.' },
{
type: 'file',
file: {
filename: 'requirements.pdf',
file_data: 'https://example.com/requirements.pdf'
}
}
]
}
],
stream: true,
max_tokens: 4096,
top_p: 0.5,
top_k: 50
})
});
Model LLM Claude Opus 4.6 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
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.6-file-analysis","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.6-file-analysis","choices":[{"index":0,"delta":{"content":"Here are the missing requirements"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.6-file-analysis","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-opus-4.6-file-analysis","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}
data: [DONE]
Respons Error
event: error
data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}}
Praktik Terbaik
- Gunakan pesan terstruktur: Kirim riwayat percakapan melalui
messages[] alih-alih meratakan konteks menjadi satu prompt.
- Pilih varian model yang tepat: Gunakan Text to Text untuk reasoning dan penulisan teks saja, dan File Analysis saat file atau gambar diperlukan.
- Sesuaikan parameter Claude dengan hati-hati:
top_p dan top_k didukung dan dapat mengubah keragaman output.
- Konsumsi event SSE: Tambahkan
choices[0].delta.content untuk tampilan streaming dan gunakan data: [DONE] sebagai respons final.
- Kirim hanya input yang didukung: Model Text mengabaikan bagian file dan gambar yang tidak didukung di client saat ini.