import { generateText, isStepCount } from 'ai';
import { fatstackTools } from '@fatstack/ai-sdk-tools';
import { privateKeyToAccount } from 'viem/accounts';
// Discovery is free and happens once; only calling a tool costs anything.
//
// The public catalogue is on Base mainnet, so calls spend real USDC. The
// required guards bound spending and cannot be raised by the model.
const tools = await fatstackTools({
wallet: privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`),
networks: ['base'],
guards: { maxPerDay: 0.5, maxPerCall: 0.01 },
});
const { text } = await generateText({
model: 'openai/gpt-5-mini',
prompt: 'Convert 20 degrees Celsius to Fahrenheit.',
tools,
stopWhen: isStepCount(3),
});
console.log(text);