Integrations Overview
Cycles integrates with LLM providers, agent frameworks, and web servers. Each integration wraps model calls with the reserve → commit → release lifecycle so that every call is budget-checked before execution.
Supported integrations
| Integration | Language | Streaming | Pattern |
|---|---|---|---|
| LLM Providers | |||
| OpenAI (Python) | Python | Yes | Decorator |
| OpenAI (TypeScript) | TypeScript | Yes | withCycles / reserveForStream |
| Anthropic (Python) | Python | Yes | Decorator |
| Anthropic (TypeScript) | TypeScript | Yes | withCycles / reserveForStream |
| AWS Bedrock | TypeScript | Yes | withCycles / reserveForStream |
| Google Gemini | TypeScript | Yes | withCycles / reserveForStream |
| Groq | Python / TypeScript | — | Decorator / withCycles |
| Ollama / Local LLMs | Python / TypeScript | — | Decorator / withCycles |
| AI Frameworks | |||
| LangChain | Python | Yes | Callback handler |
| LangChain.js | TypeScript | Yes | Callback handler |
| LangGraph | Python | — | Callback handler / Decorator |
| Vercel AI SDK | TypeScript | Yes | reserveForStream |
| Spring AI | Java | Yes | @Cycles annotation |
| LlamaIndex | Python | — | Decorator |
| CrewAI | Python | — | Decorator |
| Pydantic AI | Python | — | Decorator |
| AnyAgent | Python | — | Callback (lifecycle hooks) |
| AutoGen | Python | — | Model client wrapper |
| Agent Platforms | |||
| MCP Server | TypeScript (Node.js) | — | MCP tools |
| OpenAI Agents | Python | — | RunHooks (lifecycle hooks) |
| OpenClaw | TypeScript | Yes | Plugin (lifecycle hooks) |
| Runtime SDKs | |||
| Rust | Rust | — | Programmatic client |
| Web Frameworks | |||
| Next.js | TypeScript | Yes | withCycles / Middleware |
| Express | TypeScript | Yes | Middleware / withCycles |
| Django | Python | — | Middleware / Decorator |
| Flask | Python | — | Decorator / before_request |
| FastAPI | Python | — | Middleware / Decorator |
Integration patterns
Cycles offers several integration approaches depending on your stack:
MCP Server
The zero-code approach. Add the Cycles MCP Server to your AI agent's tool configuration and the agent gets direct access to budget tools via the Model Context Protocol. No SDK integration in the agent's code required — the agent discovers and calls cycles_reserve, cycles_commit, and other tools through standard MCP tool discovery.
Best for: Claude Desktop, Claude Code, Cursor, Windsurf, and any MCP-compatible AI host.
Decorator / Higher-order function
The simplest approach. Wrap your LLM-calling function and Cycles handles reservation, commit, and release automatically.
- Python:
@cyclesdecorator - TypeScript:
withCycleshigher-order function
Best for: individual model calls, simple request-response flows.
RunHooks / Lifecycle hooks
For agent frameworks that expose lifecycle hooks. A plugin implements the framework's hook interface to create reservations on start and commit on end — covering the entire agent run automatically.
- OpenAI Agents SDK:
CyclesRunHooksimplements the SDK'sRunHooksinterface - OpenClaw: Plugin hooks into
before_model_resolve,before_tool_call, etc.
Best for: multi-agent workflows, tool governance, agent handoff tracking.
Callback handler
For agent frameworks like LangChain that fire events on every LLM call. A custom callback handler creates reservations on llm_start and commits on llm_end.
Best for: multi-turn agents, tool-calling chains, LangChain/LangGraph pipelines.
reserveForStream
For streaming responses where the actual cost is only known after the stream completes. Reserves budget upfront, auto-extends the reservation TTL during streaming, and commits actual usage when the stream finishes.
Best for: streaming chat UIs, Vercel AI SDK, any provider with streaming support.
Programmatic client
Direct access to the Cycles client for full control over the reservation lifecycle. Use when the higher-level patterns don't fit your architecture.
Best for: custom frameworks, complex orchestration, batch processing.
See Choosing the Right Integration Pattern for detailed guidance.
Adding a new integration
All integrations follow the same protocol:
- Reserve budget before the LLM call with an estimated cost
- Execute the model call (respecting any caps returned)
- Commit actual cost from token usage after execution
- Release on error to free held budget
See Using the Cycles Client Programmatically for the full client API reference.
Webhook & Observability Integrations
Cycles emits webhook events for budget state changes, reservation denials, tenant lifecycle, and more. Connect to external alerting and incident management systems:
| Integration | Use Case | Guide |
|---|---|---|
| PagerDuty | On-call incident response for budget exhaustion and over-limit | Webhook Integrations |
| Slack | Channel notifications for budget thresholds and tenant alerts | Webhook Integrations |
| ServiceNow | Incident creation for critical budget events | Webhook Integrations |
| Custom receiver | Direct HTTP endpoint with HMAC verification | Webhook Integrations |
See Webhook Integrations for full examples with signature verification code in Python, Node.js, and Go.
Next steps
- Adding Cycles to an Existing Application — step-by-step guide for your first integration
- Webhook Integrations — PagerDuty, Slack, ServiceNow webhook examples
- Cost Estimation Cheat Sheet — pricing reference for estimation
- Error Handling Patterns — handling budget errors across languages