API 文档
Claude Fable 5 API
Claude Fable 5 通过 Claude 兼容的 Messages API 提供长上下文推理、编程、视觉理解和智能体工作流能力,支持 100 万 token 上下文。
端点
POST https://api.defapi.org/api/v1/messages
模型
anthropic/claude-fable-5
价格
$5 input / $25 output per 1M tokens
身份验证
在 Authorization 请求头中使用 Bearer token 格式发送你的 API key。
Authorization: Bearer <your-api-key>创建消息
该端点兼容 Claude 风格的 Messages 请求,同时支持非流式 JSON 响应和流式响应。
curl https://api.defapi.org/api/v1/messages \
-H "Authorization: Bearer dk-1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-fable-5",
"messages": [
{
"role": "user",
"content": "Explain how to migrate a large Next.js codebase."
}
],
"max_tokens": 512,
"temperature": 0.7,
"stream": false
}'请求参数
| 名称 | 类型 | 说明 |
|---|---|---|
| model | string | 必填。使用 anthropic/claude-fable-5。 |
| messages | array | 必填。包含 role 和 content 的对话消息数组。 |
| max_tokens | integer | 要生成的最大 token 数。 |
| temperature | number | 控制随机性。支持范围:0 到 2。 |
| top_p | number | 核采样参数。支持范围:0 到 1。 |
| stream | boolean | 设为 true 可接收 server-sent event 风格的流式输出。 |
| stop | string | 最多 4 个生成停止序列。 |
| user | string | 你的终端用户的唯一标识。 |
流式请求
将 stream 设置为 true,即可接收 server-sent event 风格的数据块。
{
"model": "anthropic/claude-fable-5",
"messages": [
{
"role": "user",
"content": "Tell me a short story about a brave knight."
}
],
"max_tokens": 512,
"temperature": 0.7,
"stream": true
}非流式响应
成功的非流式请求会返回 assistant message 和 token usage。
{
"id": "msg_01ABCDxyz",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-fable-5",
"stop_reason": "end_turn",
"stop_sequence": null,
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"usage": {
"input_tokens": 20,
"output_tokens": 50,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0
}
}错误响应
400
请求错误
参数无效或缺少必填字段。
401
未授权
API key 无效或缺失。
500
服务器内部错误
服务端发生非预期错误。