Documentation/Core Concepts/Agentic Tool Call Metering
Agentic Tool Call Metering
Autonomous AI agents do more than stream text—they search the web, scrape websites, and run Python sandboxes.
The Multi-Step Agent Problem
A single user request might use $0.001 in LLM tokens, but execute:
- ✓1 Google Search ($0.010)
- ✓1 Web Scraper ($0.005)
- ✓1 Python Sandbox execution ($0.020)
Total real cost: $0.036. If you only meter the LLM tokens, you lose money on the tools.
Using vibezcheck.session()
Create a scoped customer session to bill prompts and tools together into one customer balance:
typescript
import { generateText, tool } from 'ai';import { vibezcheck } from 'vibezcheck';import { z } from 'zod';export async function POST(req: Request) { const { prompt, customer = 'alex@company.com' } = await req.json(); // ⚡ 1. Create a unified customer session const session = vibezcheck.session({ customer }); const result = await generateText({ model: session.model('openai/gpt--mini'), tools: { searchWeb: tool({ description: 'Live Google Web Search', parameters: z.object({ query: z.string() }), execute: async ({ query }) => { // ⚡ 2. Bill external tool cost ($0.01) into the same balance await session.trackTool('google_search', { costUSD: 0.01 }); return `Results for: ${query}`; }, }), }, prompt, }); return Response.json(result);}💡 Tip: Use Left / Right arrow keys to navigate guidesPage 8 of 15