Claude Fable 5 API
由 Anthropic 驅動的 Claude Fable 5 LLM 模型完整 API 參考。
模型變體
此 API 支援三種 Claude Fable 5 模型變體:
快速比較
Claude Fable 5 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-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
端點
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-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
端點
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-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
})
});
回應格式
Claude Fable 5 LLM 模型返回相容 OpenAI 的 completion 回應。使用 stream: true 時,回應為 Server-Sent Events;使用 stream: false 時,回應為單一 JSON 物件。
成功回應
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]
錯誤回應
event: error
data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}}
最佳實踐
- 使用結構化訊息: 透過
messages[] 傳送對話歷史,而不是把上下文壓平成單一 prompt。
- 選擇正確的模型變體: 純文字推理使用 Text to Text,需要目前線上上下文時使用 Web Search,需要檔案或圖像時使用 File Analysis。
- 謹慎調整 Claude 參數:
top_p 和 top_k 在 Claude Fable 5 各變體中均受支援,且可以改變輸出多樣性。
- 消費 SSE 事件: 為串流顯示追加
choices[0].delta.content,並將 data: [DONE] 視為成功完成。
- 只傳送受支援的輸入: 不要向 Text to Text 或 Web Search 路由傳送檔案或圖像部分。