Methodfable5_delegate.py
fable5-delegate: escalate to Fable 5, fall back to Opus 4.8
A small escalation boundary for Claude Fable 5. Sends the hardest slice of a job to the most capable model, handles the four API changes that break older code, and falls back to Opus 4.8 on a refusal.
fable5_delegate.py
# fable5-delegate (minimal). Escalate a hard task to Claude Fable 5 with a
# transparent fallback to Claude Opus 4.8. Requires: anthropic>=0.116 and
# ANTHROPIC_API_KEY. The full hardened version (automatic client-side degrade,
# streaming, cost readout, offline self-test) is downloadable at:
# enapragma.co/resources/fable5-delegate/fable5_delegate.py
import anthropic
def delegate(prompt, effort="high", max_tokens=16000):
client = anthropic.Anthropic()
msg = client.beta.messages.create(
model="claude-fable-5",
max_tokens=max_tokens,
messages=[{"role": "user", "content": prompt}],
# Depth control. Do NOT send a thinking param (always-on on Fable 5;
# disabling it 400s) and do NOT send temperature/top_p/top_k (removed on
# Fable 5; sending them 400s).
output_config={"effort": effort},
# Opt into recovery so a classifier false-positive on benign work does not
# just fail: a refused request is re-served by Opus 4.8 in the same call.
betas=["server-side-fallback-2026-06-01"],
extra_body={"fallbacks": [{"model": "claude-opus-4-8"}]},
)
# A refusal is HTTP 200 with stop_reason == "refusal" and an empty content
# array. Check it BEFORE reading content, or you index into an empty list.
if msg.stop_reason == "refusal":
return None, msg.model # the whole chain declined
text = "".join(b.text for b in msg.content if getattr(b, "type", "") == "text")
return text, msg.model # msg.model tells you which model actually served it
if __name__ == "__main__":
import sys
answer, served_by = delegate(sys.argv[1])
print(answer if answer is not None else "[refused by the full chain]")
print("served by:", served_by, file=sys.stderr)This method is published in full in the post Claude Fable 5 Moves to Usage Credits Tomorrow. Here Is the Part That Actually Matters to Builders., which covers the evidence behind it and when to reach for it.