Skip to content

Fable 5 壓縮上下文

壓縮上下文版本會在送往模型前縮減較舊的對話內容,適合長時間代理工作。它使用專用模型 ID 並僅支援 Anthropic 格式。

  • 在 Claude Code 或 Anthropic SDK 中選擇壓縮版本的公開模型 ID。
  • 壓縮會減少長對話的輸入 token,但短對話不一定更便宜。
  • 快取與上下文壓縮可同時使用;請以 usage 資料比較實際效果。

完整範例

原始指南中的可執行範例完整保留如下。請只執行適用於您所用工具和作業系統的區塊。

json
"ANTHROPIC_MODEL": "anthropic/claude-fable-5-compressed-context"
bash
curl https://nordrouter.com/v1/messages \
  -H "x-api-key: sk-nr-YOUR-KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "anthropic/claude-fable-5-compressed-context",
    "max_tokens": 1024,
    "messages": [{ "role": "user", "content": "Hello!" }]
  }'
python
from anthropic import Anthropic

client = Anthropic(base_url="https://nordrouter.com", api_key="sk-nr-YOUR-KEY")

resp = client.messages.create(
    model="anthropic/claude-fable-5-compressed-context",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.content[0].text)

官方資料與相關連結

prompt_tokensInput cost
claude-fable-55,053~$0.0078
claude-fable-5-compressed-context1,287~$0.0020
ScenarioModel
Agentic coding, long chats, large documents in contextclaude-fable-5-compressed-context — maximum savings
Verbatim quoting/auditing of huge texts, critical production pipelinesclaude-fable-5 — the regular mode
Short requests without long contextNo difference — use the regular one

相關指南

先以最小文字請求驗證連線,再加入串流、工具呼叫、圖片或其他進階功能。請勿把 API 金鑰寫入公開程式碼或瀏覽器前端。

疑難排解