Quickstart
Get Fuze running in 30 seconds.
Install
Register your tools
Call registerTools() once at startup. This sends tool metadata to the Fuze cloud so you can configure budgets and retries from the dashboard without redeploying.
import { configure, registerTools } from 'fuze-ai'
configure({
cloud: { apiKey: process.env.FUZE_API_KEY }, // from app.fuze-ai.tech
project: { projectId: 'my-agent' },
})
registerTools([
{
name: 'search',
description: 'Vector database search',
sideEffect: false,
defaults: { maxRetries: 3, maxBudget: 0.10, timeout: 10_000 },
},
{
name: 'sendInvoice',
description: 'Create and send a Stripe invoice',
sideEffect: true,
defaults: { maxRetries: 1, maxBudget: 0.05, timeout: 10_000 },
},
])No API key? Skip configure(), Fuze works fully in-process with zero config.
Wrap your functions
import { guard } from 'fuze-ai'
// Read-only tool
const search = guard(async function search(query: string) {
return await vectorDb.search(query)
})
// Side-effect with compensation (rollback on failure)
const sendInvoice = guard(
async function sendInvoice(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 cost ceilings
- Extracts actual token usage from LLM responses automatically
- Records traces with timestamps, cost, and results for every call
- Applies any per-tool config set from the Fuze dashboard (retries, budget, timeout)
Multi-step runs with createRun()
Use createRun() to group multiple tool calls into a single tracked run with shared budget and loop detection:
import { createRun } from 'fuze-ai'
const run = createRun('research-agent', { maxCostPerRun: 5.00, maxIterations: 50 })
const search = run.guard(async function search(q: string) { return vectorDb.search(q) })
const summarize = run.guard(async function summarize(docs: string[]) { return llm.summarize(docs) })
const docs = await search('quarterly revenue')
const summary = await summarize(docs)
const { totalCost } = run.getStatus() // { totalCost, totalTokensIn, totalTokensOut, stepCount }
// run.end() is optional, runs without an explicit end are treated as ongoing conversations
await run.end()MCP Proxy
Wrap any MCP server with Fuze protection, no code changes needed:
The 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:
See Configuration for the full reference.
Framework adapters
Fuze works with any framework. See the adapter guides: