Raw SDK

Use Fuze directly with the raw OpenAI or Anthropic SDK, no agent framework required. Wrap each tool with guard() and dispatch from the LLM's tool-call response.

TypeScript

typescript
import { guard } from 'fuze-ai'
import OpenAI from 'openai'

const client = new OpenAI()

const tools = {
  search: guard(async (query: string) => {
    return await vectorDb.search(query)
  }),
  send_email: guard(
    async (to: string, body: string) => {
      return await ses.sendEmail(to, body)
    },
    { sideEffect: true, compensate: recallEmail }
  ),
}

async function handleToolCall(toolCall: any) {
  const fn = tools[toolCall.function.name]
  const args = JSON.parse(toolCall.function.arguments)
  return await fn(...Object.values(args))
}

Python

python
from fuze_ai import guard
from anthropic import Anthropic

client = Anthropic()

@guard
def search(query: str):
    return vector_db.search(query)

@guard(side_effect=True, compensate=recall_email)
def send_email(to: str, body: str):
    return ses.send_email(to, body)

tools = {"search": search, "send_email": send_email}

def handle_tool_use(tool_use):
    fn = tools[tool_use.name]
    return fn(**tool_use.input)

Batch wrapping

from fuze_ai import guard_all

guarded = guard_all(
    {"search": search_fn, "calculate": calc_fn, "send_email": email_fn},
    side_effects=["send_email"]
)

Run any of the snippets above and Fuze writes a JSONL trace per call to ./fuze-traces.jsonl:

jsonl
{"event":"step.end","tool":"search","cost":0.005,"tokens_in":12,"tokens_out":80}
{"event":"step.end","tool":"send_email","cost":0.0,"side_effect":true,"idempotency_key":"se_..."}