Conversation
…aming integrations Five new how-to documentation pages with code examples and best practices: - Integrating with OpenAI: cost estimation, caps, metrics - Integrating with Anthropic: decorator + per-tool-call budget tracking - Integrating with LangChain: custom callback handler pattern - Integrating with FastAPI: middleware, DI, per-tenant isolation - Handling Streaming Responses: reserve → stream → commit pattern Updates VitePress sidebar to include the new pages. https://claude.ai/code/session_019RuDwakEwtZDbEMYNvesUF
- Remove tenant=lambda from @cycles decorator in FastAPI guide (tenant parameter only accepts str | None, not callables) - Fix exception constructor calls in LangChain guide to pass message as first positional argument https://claude.ai/code/session_019RuDwakEwtZDbEMYNvesUF
…ain guide Matches the fix applied to the example files for consistency. https://claude.ai/code/session_019RuDwakEwtZDbEMYNvesUF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive how-to guides for integrating the Cycles budget management system with popular Python frameworks and LLM providers. These guides provide practical patterns for cost-controlling API calls across different use cases.
Changes
OpenAI Integration Guide (
how-to/integrating-cycles-with-openai.md): Demonstrates the@cyclesdecorator pattern for guarding chat completions with budget reservations, cost estimation strategies, budget exhaustion handling, and metrics reporting.Anthropic Integration Guide (
how-to/integrating-cycles-with-anthropic.md): Shows both decorator-based simple calls and programmatic per-turn budget tracking for agentic workflows with tool use, including pricing reference table.LangChain Integration Guide (
how-to/integrating-cycles-with-langchain.md): Explains the callback handler approach (CyclesBudgetHandler) for wrapping every LLM call in LangChain applications, with examples for chat models and agents with tools.FastAPI Integration Guide (
how-to/integrating-cycles-with-fastapi.md): Covers client lifecycle management, exception handlers for budget errors, preflight middleware withdecide(), per-tenant isolation, and budget dashboard endpoints.Streaming Responses Guide (
how-to/handling-streaming-responses-with-cycles.md): Addresses the reserve → stream → commit pattern for streaming LLM responses, TTL considerations, release-on-failure semantics, and cap respecting.Documentation Navigation: Updated
.vitepress/config.tsto include the new guides in the sidebar navigation under the how-to section.Notable Implementation Details
https://claude.ai/code/session_019RuDwakEwtZDbEMYNvesUF