Quickstart
Get Fuze running in 30 seconds.
Install
# TypeScript / Node.js
npm install fuze-ai
# Python
pip install fuze-aiBasic usage
import { guard } from 'fuze-ai'
// Wrap any async function
const search = guard(async (query: string) => {
return await vectorDb.search(query)
})
// Mark side-effects with compensation
const sendInvoice = guard(
async (id: string, amount: number) => {
return await stripe.createInvoice(id, amount)
},
{ sideEffect: true, compensate: cancelInvoice }
)
// Use normally — Fuze protects automatically
const results = await search('quarterly revenue')What happens automatically
When you wrap a function with guard(), Fuze:
- Tracks iterations and counts how many times the function is called within a run
- Detects loops by hashing tool+args to catch identical repeated calls
- Monitors budget against configured token and cost ceilings
- Records traces with timestamps, cost, and results for every call
- Tracks side-effects and marks which calls changed the real world
Multi-step runs with createRun()
Use createRun() to group multiple tool calls into a single tracked run with shared budget and loop detection:
import { guard, createRun } from 'fuze-ai'
const search = guard(async (query: string) => {
return await vectorDb.search(query)
})
const summarize = guard(async (text: string) => {
return await llm.summarize(text)
})
// Create a run with budget limits
const run = createRun({ maxCost: 5.00, maxIterations: 50 })
// All calls within the run share the same budget and trace
const results = await run.call(search, 'quarterly revenue')
const summary = await run.call(summarize, results.text)
const deeper = await run.call(search, summary.followUpQuery)
// Finalize the run — flushes traces and releases resources
await run.end()MCP Proxy
Wrap any MCP server with Fuze protection — no code changes needed:
npx fuze-ai proxy -- <server-command>
# Example: protect a Postgres MCP server
npx fuze-ai proxy -- npx @modelcontextprotocol/server-postgresThe proxy intercepts every tools/call request, applies budget checks and loop detection, then forwards to the real server. See MCP Proxy for full details.
Add configuration
Create a fuze.toml in your project root:
[defaults]
max_retries = 3
timeout = "30s"
max_cost_per_step = 1.00
max_cost_per_run = 10.00
max_iterations = 25
kill_on_loop = trueSee Configuration for the full reference.
Framework adapters
Fuze works with any framework. See the adapter guides:
Examples
See Examples for end-to-end usage patterns including multi-agent workflows, MCP proxy setups, and compliance configurations.