// Runnable example: the 5 Lordevo tools as Vercel AI SDK tools, each executed once the way generateText would. // No LLM key needed. Without AGENT_WALLET_KEY only free trial calls work (3 per IP per UTC day). // node example.mjs // Env: AGENT_WALLET_KEY (optional, a Base wallet holding a little USDC), LORDEVO_BASE_URL (default the live shop), // LORDEVO_EXAMPLE_SITE (default https://example.com, the catalog's example input). import { createLordevo, fromPrivateKey } from 'lordevo-x402'; import { lordevoTools } from './lordevo-ai-sdk.mjs'; const baseUrl = process.env.LORDEVO_BASE_URL || 'https://shop.lordevo.com'; const site = process.env.LORDEVO_EXAMPLE_SITE || 'https://example.com'; const host = new URL(site).hostname; const lordevo = process.env.AGENT_WALLET_KEY ? await fromPrivateKey(process.env.AGENT_WALLET_KEY, { baseUrl, trial: true, maxPriceUsd: 0.01 }) // free calls first, then pays : createLordevo({ baseUrl, trial: true }); // free trial calls only const tools = lordevoTools(lordevo); const calls = [ ['page_markdown', { url: site }], ['can_fetch', { url: `${site}/blog/post` }], ['tech_stack', { url: site }], ['dns_lookup', { host, type: 'MX' }], ['email_validate', { email: `jane@${host}` }], ['can_fetch', { url: 'ftp://not-a-web-url' }], // bad input: an instant tool that fails is not charged ]; const out = []; for (const [name, input] of calls) { const body = await tools[name].execute(input, { toolCallId: `example-${out.length}`, messages: [] }); out.push({ tool: name, ok: !body.error, free_trial: !!body._trial?.free, error: body.error || null, charged: body.error ? body.charged : undefined }); console.log(name, body.error ? `error ${body.error}: ${body.message}` : `ok${body._trial?.free ? ' (free trial)' : ''}`); } console.log('RESULT ' + JSON.stringify({ framework: 'vercel-ai-sdk', tools: Object.keys(tools), schema_keys: Object.keys((await tools.page_markdown.inputSchema.jsonSchema)?.properties || {}), calls: out }));