anthropics / anthropics/claude-cookbooks
[PROPOSAL] Cookbook: Live Token Budget Tracker for Streaming Responses
- Langage dominant
- Jupyter Notebook
- Étoiles
- 52.7k
- Forks
- 6.3k
- Merge moyen
- 25 min
- PR mergées (30 j)
- 6
Description
**Problem Statement**: Developers streaming Claude responses often lose track of token usage mid-stream, making it hard to stay within budget limits. Existing examples don't show real-time token tracking during streaming.
**Preflight Checklist**:
- [x] I have searched existing cookbooks and this topic isn't already covered
- [x] This proposal focuses on Claude API/SDK capabilities (not external frameworks)
- [x] I am prepared to implement this cookbook (or have a clear implementation plan)
**Claude Capabilities Demonstrated**:
- Streaming responses (stream API with streamUsage: true)
- Real-time token counting from streaming deltas
- Budget monitoring and early termination
- Usage telemetry for cost control
**Differentiation**: No existing cookbook shows live token tracking during streaming. The closest is the sampling_past_max_tokens notebook, but that doesn't cover real-time streaming scenarios.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.