API Claude Fable 5
Referensi API lengkap untuk model LLM Claude Fable 5 yang didukung oleh Anthropic.
Varian Model
API ini mendukung tiga varian model Claude Fable 5:
Perbandingan Singkat
Claude Fable 5 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-fable-5-text-to-text',
messages: [
{
role: 'user',
content: 'Draft a technical decision memo for this architecture choice.'
}
],
stream: true,
max_tokens: 2048,
top_p: 0.9,
top_k: 50
})
});
Claude Fable 5 Web Search
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-fable-5-web-search',
messages: [
{
role: 'user',
content: 'Find the latest public information about Claude Fable 5 and summarize it for a product brief.'
}
],
stream: true,
max_tokens: 2048,
top_p: 0.9,
top_k: 50
})
});
Claude Fable 5 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-fable-5-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.9,
top_k: 50
})
});
Model LLM Claude Fable 5 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-fable-5-file-analysis","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-fable-5-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-fable-5-file-analysis","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"claude-fable-5-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 penalaran khusus teks, Web Search ketika konteks online terbaru diperlukan, dan File Analysis ketika file atau gambar diperlukan.
- Atur parameter Claude dengan cermat:
top_p dan top_k didukung di semua varian Claude Fable 5 dan dapat mengubah keragaman output.
- Konsumsi event SSE: Tambahkan
choices[0].delta.content untuk tampilan streaming dan perlakukan data: [DONE] sebagai penyelesaian yang berhasil.
- Kirim hanya input yang didukung: Jangan kirim bagian file atau gambar ke rute Text to Text atau Web Search.