Quickstart

Get Fuze running in 30 seconds.

Install

bash
# TypeScript / Node.js
npm install fuze-ai

# Python
pip install fuze-ai

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:

  1. Tracks iterations and counts how many times the function is called within a run
  2. Detects loops by hashing tool+args to catch identical repeated calls
  3. Monitors budget against configured cost ceilings
  4. Extracts actual token usage from LLM responses automatically
  5. Records traces with timestamps, cost, and results for every call
  6. 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:

bash
npx fuze-ai proxy -- <server-command>

# Example: protect a Postgres MCP server
npx fuze-ai proxy -- npx @modelcontextprotocol/server-postgres

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:

toml
[defaults]
max_retries = 3
timeout = "30s"
max_cost_per_run = 10.00
max_iterations = 25

[cloud]
api_key = ""   # or set FUZE_API_KEY env var

[project]
project_id = "my-agent"

See Configuration for the full reference.

Framework adapters

Fuze works with any framework. See the adapter guides: