[{"data":1,"prerenderedAt":1156},["ShallowReactive",2],{"navigation_docs":3,"-logging-ai-sdk-options":402,"-logging-ai-sdk-options-surround":1151},[4,35,159,201,289,299,386],{"title":5,"path":6,"stem":7,"children":8,"page":34},"Getting Started","\u002Fgetting-started","1.getting-started",[9,14,19,24,29],{"title":10,"path":11,"stem":12,"icon":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-info",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":20,"path":21,"stem":22,"icon":23},"Quick Start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start","i-lucide-zap",{"title":25,"path":26,"stem":27,"icon":28},"Agent Skills","\u002Fgetting-started\u002Fagent-skills","1.getting-started\u002F4.agent-skills","i-lucide-sparkles",{"title":30,"path":31,"stem":32,"icon":33},"vs Other Loggers","\u002Fgetting-started\u002Fvs-other-loggers","1.getting-started\u002F5.vs-other-loggers","i-lucide-scale",false,{"title":36,"path":37,"stem":38,"children":39,"page":34},"Logging","\u002Flogging","2.logging",[40,45,50,55,60,65,70,99,127],{"title":41,"path":42,"stem":43,"icon":44},"Overview","\u002Flogging\u002Foverview","2.logging\u002F0.overview","i-lucide-list",{"title":46,"path":47,"stem":48,"icon":49},"Simple Logging","\u002Flogging\u002Fsimple-logging","2.logging\u002F1.simple-logging","i-lucide-terminal",{"title":51,"path":52,"stem":53,"icon":54},"Wide Events","\u002Flogging\u002Fwide-events","2.logging\u002F2.wide-events","i-lucide-layers",{"title":56,"path":57,"stem":58,"icon":59},"Structured Errors","\u002Flogging\u002Fstructured-errors","2.logging\u002F3.structured-errors","i-lucide-shield-alert",{"title":61,"path":62,"stem":63,"icon":64},"Catalogs","\u002Flogging\u002Fcatalogs","2.logging\u002F4.catalogs","i-lucide-book-open",{"title":66,"path":67,"stem":68,"icon":69},"Client Logging","\u002Flogging\u002Fclient-logging","2.logging\u002F5.client-logging","i-lucide-monitor",{"title":71,"icon":72,"path":73,"stem":74,"children":75,"page":34},"AI SDK","i-simple-icons-vercel","\u002Flogging\u002Fai-sdk","2.logging\u002F6.ai-sdk",[76,79,84,89,94],{"title":41,"path":77,"stem":78,"icon":44},"\u002Flogging\u002Fai-sdk\u002Foverview","2.logging\u002F6.ai-sdk\u002F01.overview",{"title":80,"path":81,"stem":82,"icon":83},"Usage","\u002Flogging\u002Fai-sdk\u002Fusage","2.logging\u002F6.ai-sdk\u002F02.usage","i-lucide-code",{"title":85,"path":86,"stem":87,"icon":88},"Options","\u002Flogging\u002Fai-sdk\u002Foptions","2.logging\u002F6.ai-sdk\u002F03.options","i-lucide-sliders",{"title":90,"path":91,"stem":92,"icon":93},"Metadata","\u002Flogging\u002Fai-sdk\u002Fmetadata","2.logging\u002F6.ai-sdk\u002F04.metadata","i-lucide-database",{"title":95,"path":96,"stem":97,"icon":98},"Telemetry","\u002Flogging\u002Fai-sdk\u002Ftelemetry","2.logging\u002F6.ai-sdk\u002F05.telemetry","i-lucide-activity",{"title":100,"icon":101,"path":102,"stem":103,"children":104,"page":34},"Better Auth","i-simple-icons-betterauth","\u002Flogging\u002Fbetter-auth","2.logging\u002F7.better-auth",[105,108,113,118,122],{"title":41,"path":106,"stem":107,"icon":44},"\u002Flogging\u002Fbetter-auth\u002Foverview","2.logging\u002F7.better-auth\u002F01.overview",{"title":109,"path":110,"stem":111,"icon":112},"Identify User","\u002Flogging\u002Fbetter-auth\u002Fidentify-user","2.logging\u002F7.better-auth\u002F02.identify-user","i-lucide-user-check",{"title":114,"path":115,"stem":116,"icon":117},"Middleware","\u002Flogging\u002Fbetter-auth\u002Fmiddleware","2.logging\u002F7.better-auth\u002F03.middleware","i-lucide-shield",{"title":119,"path":120,"stem":121,"icon":69},"Client Sync","\u002Flogging\u002Fbetter-auth\u002Fclient-sync","2.logging\u002F7.better-auth\u002F04.client-sync",{"title":123,"path":124,"stem":125,"icon":126},"Performance","\u002Flogging\u002Fbetter-auth\u002Fperformance","2.logging\u002F7.better-auth\u002F05.performance","i-lucide-gauge",{"title":128,"icon":129,"path":130,"stem":131,"children":132,"page":34},"Audit Logs","i-lucide-shield-check","\u002Flogging\u002Faudit","2.logging\u002F8.audit",[133,136,141,146,151,155],{"title":41,"path":134,"stem":135,"icon":44},"\u002Flogging\u002Faudit\u002Foverview","2.logging\u002F8.audit\u002F01.overview",{"title":137,"path":138,"stem":139,"icon":140},"Schema","\u002Flogging\u002Faudit\u002Fschema","2.logging\u002F8.audit\u002F02.schema","i-lucide-file-text",{"title":142,"path":143,"stem":144,"icon":145},"Recording","\u002Flogging\u002Faudit\u002Frecording","2.logging\u002F8.audit\u002F03.recording","i-lucide-pen-line",{"title":147,"path":148,"stem":149,"icon":150},"Drains","\u002Flogging\u002Faudit\u002Fpipeline","2.logging\u002F8.audit\u002F04.pipeline","i-lucide-link",{"title":152,"path":153,"stem":154,"icon":129},"Compliance","\u002Flogging\u002Faudit\u002Fcompliance","2.logging\u002F8.audit\u002F05.compliance",{"title":156,"path":157,"stem":158,"icon":64},"Recipes","\u002Flogging\u002Faudit\u002Frecipes","2.logging\u002F8.audit\u002F06.recipes",{"title":160,"path":161,"stem":162,"children":163,"page":34},"Core Concepts","\u002Fcore-concepts","3.core-concepts",[164,169,174,179,184,188,191,196],{"title":165,"path":166,"stem":167,"icon":168},"Lifecycle","\u002Fcore-concepts\u002Flifecycle","3.core-concepts\u002F0.lifecycle","i-lucide-arrow-right-left",{"title":170,"path":171,"stem":172,"icon":173},"Configuration","\u002Fcore-concepts\u002Fconfiguration","3.core-concepts\u002F1.configuration","i-lucide-settings",{"title":175,"path":176,"stem":177,"icon":178},"Sampling","\u002Fcore-concepts\u002Fsampling","3.core-concepts\u002F2.sampling","i-lucide-filter",{"title":180,"path":181,"stem":182,"icon":183},"Typed Fields","\u002Fcore-concepts\u002Ftyped-fields","3.core-concepts\u002F3.typed-fields","i-simple-icons-typescript",{"title":185,"path":186,"stem":187,"icon":129},"Best Practices","\u002Fcore-concepts\u002Fbest-practices","3.core-concepts\u002F4.best-practices",{"title":123,"path":189,"stem":190,"icon":126},"\u002Fcore-concepts\u002Fperformance","3.core-concepts\u002F5.performance",{"title":192,"path":193,"stem":194,"icon":195},"Vite Plugin","\u002Fcore-concepts\u002Fvite-plugin","3.core-concepts\u002F6.vite-plugin","i-custom-vite",{"title":197,"path":198,"stem":199,"icon":200},"Auto-Redaction","\u002Fcore-concepts\u002Fredaction","3.core-concepts\u002F7.redaction","i-lucide-eye-off",{"title":202,"path":203,"stem":204,"children":205,"page":34},"Frameworks","\u002Fframeworks","4.frameworks",[206,210,215,220,225,230,235,240,245,250,255,260,265,270,274,279,284],{"title":41,"path":207,"stem":208,"icon":209},"\u002Fframeworks\u002Foverview","4.frameworks\u002F00.overview","i-lucide-layout-grid",{"title":211,"path":212,"stem":213,"icon":214},"Nuxt","\u002Fframeworks\u002Fnuxt","4.frameworks\u002F01.nuxt","i-simple-icons-nuxtdotjs",{"title":216,"path":217,"stem":218,"icon":219},"Next.js","\u002Fframeworks\u002Fnextjs","4.frameworks\u002F02.nextjs","i-simple-icons-nextdotjs",{"title":221,"path":222,"stem":223,"icon":224},"SvelteKit","\u002Fframeworks\u002Fsveltekit","4.frameworks\u002F03.sveltekit","i-simple-icons-svelte",{"title":226,"path":227,"stem":228,"icon":229},"Nitro","\u002Fframeworks\u002Fnitro","4.frameworks\u002F04.nitro","i-custom-nitro",{"title":231,"path":232,"stem":233,"icon":234},"TanStack Start","\u002Fframeworks\u002Ftanstack-start","4.frameworks\u002F05.tanstack-start","i-custom-tanstack",{"title":236,"path":237,"stem":238,"icon":239},"NestJS","\u002Fframeworks\u002Fnestjs","4.frameworks\u002F06.nestjs","i-simple-icons-nestjs",{"title":241,"path":242,"stem":243,"icon":244},"Express","\u002Fframeworks\u002Fexpress","4.frameworks\u002F07.express","i-simple-icons-express",{"title":246,"path":247,"stem":248,"icon":249},"Hono","\u002Fframeworks\u002Fhono","4.frameworks\u002F08.hono","i-simple-icons-hono",{"title":251,"path":252,"stem":253,"icon":254},"Fastify","\u002Fframeworks\u002Ffastify","4.frameworks\u002F09.fastify","i-simple-icons-fastify",{"title":256,"path":257,"stem":258,"icon":259},"Elysia","\u002Fframeworks\u002Felysia","4.frameworks\u002F10.elysia","i-custom-elysia",{"title":261,"path":262,"stem":263,"icon":264},"React Router","\u002Fframeworks\u002Freact-router","4.frameworks\u002F11.react-router","i-custom-reactrouter",{"title":266,"path":267,"stem":268,"icon":269},"Cloudflare Workers","\u002Fframeworks\u002Fcloudflare-workers","4.frameworks\u002F12.cloudflare-workers","i-simple-icons-cloudflare",{"title":271,"path":272,"stem":273,"icon":183},"Standalone","\u002Fframeworks\u002Fstandalone","4.frameworks\u002F13.standalone",{"title":275,"path":276,"stem":277,"icon":278},"Astro","\u002Fframeworks\u002Fastro","4.frameworks\u002F14.astro","i-simple-icons-astro",{"title":280,"path":281,"stem":282,"icon":283},"AWS Lambda","\u002Fframeworks\u002Faws-lambda","4.frameworks\u002F16.aws-lambda","i-custom-lambda",{"title":285,"path":286,"stem":287,"icon":288},"Custom Integration","\u002Fframeworks\u002Fcustom-integration","4.frameworks\u002F17.custom-integration","i-lucide-puzzle",{"title":290,"path":291,"stem":292,"children":293,"page":34},"Build On Top","\u002Fbuild-on-top","5.build-on-top",[294],{"title":295,"path":296,"stem":297,"icon":298},"FS reader","\u002Fbuild-on-top\u002Ffs-reader","5.build-on-top\u002F4.fs-reader","i-lucide-folder-search",{"title":300,"path":301,"stem":302,"children":303,"page":34},"Adapters","\u002Fadapters","6.adapters",[304,307,347,362],{"title":41,"path":305,"stem":306,"icon":44},"\u002Fadapters\u002Foverview","6.adapters\u002F01.overview",{"title":308,"path":309,"stem":310,"children":311,"page":34},"Cloud destinations","\u002Fadapters\u002Fcloud","6.adapters\u002F02.cloud",[312,317,322,327,332,337,342],{"title":313,"path":314,"stem":315,"icon":316},"Axiom","\u002Fadapters\u002Fcloud\u002Faxiom","6.adapters\u002F02.cloud\u002F01.axiom","i-custom-axiom",{"title":318,"path":319,"stem":320,"icon":321},"OTLP","\u002Fadapters\u002Fcloud\u002Fotlp","6.adapters\u002F02.cloud\u002F02.otlp","i-simple-icons-opentelemetry",{"title":323,"path":324,"stem":325,"icon":326},"PostHog","\u002Fadapters\u002Fcloud\u002Fposthog","6.adapters\u002F02.cloud\u002F03.posthog","i-simple-icons-posthog",{"title":328,"path":329,"stem":330,"icon":331},"Sentry","\u002Fadapters\u002Fcloud\u002Fsentry","6.adapters\u002F02.cloud\u002F04.sentry","i-simple-icons-sentry",{"title":333,"path":334,"stem":335,"icon":336},"Better Stack","\u002Fadapters\u002Fcloud\u002Fbetter-stack","6.adapters\u002F02.cloud\u002F05.better-stack","i-simple-icons-betterstack",{"title":338,"path":339,"stem":340,"icon":341},"Datadog","\u002Fadapters\u002Fcloud\u002Fdatadog","6.adapters\u002F02.cloud\u002F06.datadog","i-simple-icons-datadog",{"title":343,"path":344,"stem":345,"icon":346},"HyperDX","\u002Fadapters\u002Fcloud\u002Fhyperdx","6.adapters\u002F02.cloud\u002F07.hyperdx","i-custom-hyperdx",{"title":348,"path":349,"stem":350,"children":351,"page":34},"Self-hosted","\u002Fadapters\u002Fself-hosted","6.adapters\u002F03.self-hosted",[352,357],{"title":353,"path":354,"stem":355,"icon":356},"File System","\u002Fadapters\u002Fself-hosted\u002Ffs","6.adapters\u002F03.self-hosted\u002F01.fs","i-lucide-hard-drive",{"title":358,"path":359,"stem":360,"icon":361},"NuxtHub","\u002Fadapters\u002Fself-hosted\u002Fnuxthub","6.adapters\u002F03.self-hosted\u002F02.nuxthub","i-simple-icons-nuxt",{"title":363,"path":364,"stem":365,"children":366,"page":34},"Building blocks","\u002Fadapters\u002Fbuilding-blocks","6.adapters\u002F04.building-blocks",[367,372,377,381],{"title":368,"path":369,"stem":370,"icon":371},"Pipeline","\u002Fadapters\u002Fbuilding-blocks\u002Fpipeline","6.adapters\u002F04.building-blocks\u002F01.pipeline","i-lucide-workflow",{"title":373,"path":374,"stem":375,"icon":376},"HTTP","\u002Fadapters\u002Fbuilding-blocks\u002Fhttp","6.adapters\u002F04.building-blocks\u002F02.http","i-lucide-globe",{"title":378,"path":379,"stem":380,"icon":83},"Custom Adapters","\u002Fadapters\u002Fbuilding-blocks\u002Fcustom","6.adapters\u002F04.building-blocks\u002F03.custom",{"title":382,"path":383,"stem":384,"icon":385},"Toolkit","\u002Fadapters\u002Fbuilding-blocks\u002Ftoolkit","6.adapters\u002F04.building-blocks\u002F04.toolkit","i-lucide-blocks",{"title":387,"path":388,"stem":389,"children":390,"page":34},"Enrichers","\u002Fenrichers","7.enrichers",[391,394,398],{"title":41,"path":392,"stem":393,"icon":28},"\u002Fenrichers\u002Foverview","7.enrichers\u002F1.overview",{"title":395,"path":396,"stem":397,"icon":288},"Built-in","\u002Fenrichers\u002Fbuilt-in","7.enrichers\u002F2.built-in",{"title":399,"path":400,"stem":401,"icon":83},"Custom","\u002Fenrichers\u002Fcustom","7.enrichers\u002F3.custom",{"id":403,"title":85,"body":404,"description":1139,"extension":1140,"links":1141,"meta":1147,"navigation":1148,"path":86,"seo":1149,"stem":87,"__hash__":1150},"docs\u002F2.logging\u002F6.ai-sdk\u002F03.options.md",{"type":405,"value":406,"toc":1130},"minimark",[407,415,485,490,504,516,521,577,581,623,627,778,828,841,845,855,961,971,978,982,985,1119,1126],[408,409,410,414],"p",{},[411,412,413],"code",{},"createAILogger(log, options?)"," accepts a single options bag. Every option is opt-in — defaults stay safe and quiet.",[416,417,418,437],"table",{},[419,420,421],"thead",{},[422,423,424,428,431,434],"tr",{},[425,426,427],"th",{},"Option",[425,429,430],{},"Type",[425,432,433],{},"Default",[425,435,436],{},"Description",[438,439,440,461],"tbody",{},[422,441,442,448,453,458],{},[443,444,445],"td",{},[411,446,447],{},"toolInputs",[443,449,450],{},[411,451,452],{},"boolean | ToolInputsOptions",[443,454,455],{},[411,456,457],{},"false",[443,459,460],{},"Capture tool call inputs alongside their names (off by default to avoid leaking sensitive data).",[422,462,463,468,473,478],{},[443,464,465],{},[411,466,467],{},"cost",[443,469,470],{},[411,471,472],{},"Record\u003Cstring, ModelCost>",[443,474,475],{},[411,476,477],{},"undefined",[443,479,480,481,484],{},"Pricing map. Keys are model IDs, values are ",[411,482,483],{},"{ input, output }"," in dollars per 1M tokens.",[486,487,489],"h2",{"id":488},"tool-inputs","Tool Inputs",[408,491,492,493,496,497,500,501,503],{},"By default, ",[411,494,495],{},"ai.toolCalls"," is a ",[411,498,499],{},"string[]"," of tool names. Enable ",[411,502,447],{}," to capture inputs too — useful for debugging agent behaviour or auditing what data the model reached for.",[505,506,507,508,511,512,515],"warning",{},"Tool inputs can be large and may contain sensitive data (SQL, API keys, customer PII). Use ",[411,509,510],{},"maxLength"," and ",[411,513,514],{},"transform"," rather than enabling raw capture in production.",[517,518,520],"h3",{"id":519},"capture-everything","Capture everything",[522,523,528],"pre",{"className":524,"code":525,"language":526,"meta":527,"style":527},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const ai = createAILogger(log, { toolInputs: true })\n","typescript","",[411,529,530],{"__ignoreMap":527},[531,532,535,539,543,547,551,554,557,560,564,567,571,574],"span",{"class":533,"line":534},"line",1,[531,536,538],{"class":537},"spNyl","const",[531,540,542],{"class":541},"sTEyZ"," ai ",[531,544,546],{"class":545},"sMK4o","=",[531,548,550],{"class":549},"s2Zo4"," createAILogger",[531,552,553],{"class":541},"(log",[531,555,556],{"class":545},",",[531,558,559],{"class":545}," {",[531,561,563],{"class":562},"swJcz"," toolInputs",[531,565,566],{"class":545},":",[531,568,570],{"class":569},"sfNiH"," true",[531,572,573],{"class":545}," }",[531,575,576],{"class":541},")\n",[517,578,580],{"id":579},"truncate-long-inputs","Truncate long inputs",[522,582,584],{"className":524,"code":583,"language":526,"meta":527,"style":527},"const ai = createAILogger(log, { toolInputs: { maxLength: 200 } })\n",[411,585,586],{"__ignoreMap":527},[531,587,588,590,592,594,596,598,600,602,604,606,608,611,613,617,619,621],{"class":533,"line":534},[531,589,538],{"class":537},[531,591,542],{"class":541},[531,593,546],{"class":545},[531,595,550],{"class":549},[531,597,553],{"class":541},[531,599,556],{"class":545},[531,601,559],{"class":545},[531,603,563],{"class":562},[531,605,566],{"class":545},[531,607,559],{"class":545},[531,609,610],{"class":562}," maxLength",[531,612,566],{"class":545},[531,614,616],{"class":615},"sbssI"," 200",[531,618,573],{"class":545},[531,620,573],{"class":545},[531,622,576],{"class":541},[517,624,626],{"id":625},"redact-sensitive-fields","Redact sensitive fields",[522,628,630],{"className":524,"code":629,"language":526,"meta":527,"style":527},"const ai = createAILogger(log, {\n  toolInputs: {\n    maxLength: 500,\n    transform: (input, toolName) => {\n      if (toolName === 'queryDB') return { sql: '***' }\n      return input\n    },\n  },\n})\n",[411,631,632,649,659,673,701,749,758,764,770],{"__ignoreMap":527},[531,633,634,636,638,640,642,644,646],{"class":533,"line":534},[531,635,538],{"class":537},[531,637,542],{"class":541},[531,639,546],{"class":545},[531,641,550],{"class":549},[531,643,553],{"class":541},[531,645,556],{"class":545},[531,647,648],{"class":545}," {\n",[531,650,652,655,657],{"class":533,"line":651},2,[531,653,654],{"class":562},"  toolInputs",[531,656,566],{"class":545},[531,658,648],{"class":545},[531,660,662,665,667,670],{"class":533,"line":661},3,[531,663,664],{"class":562},"    maxLength",[531,666,566],{"class":545},[531,668,669],{"class":615}," 500",[531,671,672],{"class":545},",\n",[531,674,676,679,681,684,688,690,693,696,699],{"class":533,"line":675},4,[531,677,678],{"class":549},"    transform",[531,680,566],{"class":545},[531,682,683],{"class":545}," (",[531,685,687],{"class":686},"sHdIc","input",[531,689,556],{"class":545},[531,691,692],{"class":686}," toolName",[531,694,695],{"class":545},")",[531,697,698],{"class":537}," =>",[531,700,648],{"class":545},[531,702,704,708,710,713,716,719,723,726,729,732,734,737,739,741,744,746],{"class":533,"line":703},5,[531,705,707],{"class":706},"s7zQu","      if",[531,709,683],{"class":562},[531,711,712],{"class":541},"toolName",[531,714,715],{"class":545}," ===",[531,717,718],{"class":545}," '",[531,720,722],{"class":721},"sfazB","queryDB",[531,724,725],{"class":545},"'",[531,727,728],{"class":562},") ",[531,730,731],{"class":706},"return",[531,733,559],{"class":545},[531,735,736],{"class":562}," sql",[531,738,566],{"class":545},[531,740,718],{"class":545},[531,742,743],{"class":721},"***",[531,745,725],{"class":545},[531,747,748],{"class":545}," }\n",[531,750,752,755],{"class":533,"line":751},6,[531,753,754],{"class":706},"      return",[531,756,757],{"class":541}," input\n",[531,759,761],{"class":533,"line":760},7,[531,762,763],{"class":545},"    },\n",[531,765,767],{"class":533,"line":766},8,[531,768,769],{"class":545},"  },\n",[531,771,773,776],{"class":533,"line":772},9,[531,774,775],{"class":545},"}",[531,777,576],{"class":541},[416,779,780,791],{},[419,781,782],{},[422,783,784,787,789],{},[425,785,786],{},"Sub-option",[425,788,430],{},[425,790,436],{},[438,792,793,811],{},[422,794,795,799,804],{},[443,796,797],{},[411,798,510],{},[443,800,801],{},[411,802,803],{},"number",[443,805,806,807,810],{},"Truncate stringified inputs exceeding this character length (appends ",[411,808,809],{},"…",").",[422,812,813,817,822],{},[443,814,815],{},[411,816,514],{},[443,818,819],{},[411,820,821],{},"(input, toolName) => unknown",[443,823,824,825,827],{},"Custom transform applied before ",[411,826,510],{},". Use to redact fields or reshape data.",[408,829,830,831,833,834,836,837,840],{},"When ",[411,832,447],{}," is enabled, ",[411,835,495],{}," becomes an ",[411,838,839],{},"Array\u003C{ name, input }>"," instead of a plain string array.",[486,842,844],{"id":843},"cost-estimation","Cost Estimation",[408,846,847,848,850,851,854],{},"Pass a ",[411,849,467],{}," map to compute estimated dollar cost per call. The middleware multiplies token usage by the per-million rates and sets ",[411,852,853],{},"ai.estimatedCost"," on the wide event.",[522,856,858],{"className":524,"code":857,"language":526,"meta":527,"style":527},"const ai = createAILogger(log, {\n  cost: {\n    'claude-sonnet-4.6': { input: 3, output: 15 },\n    'gpt-4o': { input: 2.5, output: 10 },\n  },\n})\n",[411,859,860,876,885,920,951,955],{"__ignoreMap":527},[531,861,862,864,866,868,870,872,874],{"class":533,"line":534},[531,863,538],{"class":537},[531,865,542],{"class":541},[531,867,546],{"class":545},[531,869,550],{"class":549},[531,871,553],{"class":541},[531,873,556],{"class":545},[531,875,648],{"class":545},[531,877,878,881,883],{"class":533,"line":651},[531,879,880],{"class":562},"  cost",[531,882,566],{"class":545},[531,884,648],{"class":545},[531,886,887,890,893,895,897,899,902,904,907,909,912,914,917],{"class":533,"line":661},[531,888,889],{"class":545},"    '",[531,891,892],{"class":562},"claude-sonnet-4.6",[531,894,725],{"class":545},[531,896,566],{"class":545},[531,898,559],{"class":545},[531,900,901],{"class":562}," input",[531,903,566],{"class":545},[531,905,906],{"class":615}," 3",[531,908,556],{"class":545},[531,910,911],{"class":562}," output",[531,913,566],{"class":545},[531,915,916],{"class":615}," 15",[531,918,919],{"class":545}," },\n",[531,921,922,924,927,929,931,933,935,937,940,942,944,946,949],{"class":533,"line":675},[531,923,889],{"class":545},[531,925,926],{"class":562},"gpt-4o",[531,928,725],{"class":545},[531,930,566],{"class":545},[531,932,559],{"class":545},[531,934,901],{"class":562},[531,936,566],{"class":545},[531,938,939],{"class":615}," 2.5",[531,941,556],{"class":545},[531,943,911],{"class":562},[531,945,566],{"class":545},[531,947,948],{"class":615}," 10",[531,950,919],{"class":545},[531,952,953],{"class":533,"line":703},[531,954,769],{"class":545},[531,956,957,959],{"class":533,"line":751},[531,958,775],{"class":545},[531,960,576],{"class":541},[408,962,963,964,970],{},"Read the result from your handler with ",[965,966,967],"a",{"href":91},[411,968,969],{},"ai.getEstimatedCost()"," — useful for billing dashboards or warning users before expensive calls.",[972,973,974,975,977],"tip",{},"Keep your ",[411,976,467],{}," map in one file alongside model selection so renaming a model in production also updates pricing. Avoid hardcoding per-route maps.",[486,979,981],{"id":980},"error-handling","Error Handling",[408,983,984],{},"If a model call fails, the middleware captures the error into the wide event before re-throwing:",[522,986,991],{"className":987,"code":988,"filename":989,"language":990,"meta":527,"style":527},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"ai\": {\n    \"calls\": 1,\n    \"model\": \"claude-sonnet-4.6\",\n    \"provider\": \"anthropic\",\n    \"finishReason\": \"error\",\n    \"error\": \"API rate limit exceeded\"\n  }\n}\n","Wide Event","json",[411,992,993,998,1013,1031,1051,1071,1091,1109,1114],{"__ignoreMap":527},[531,994,995],{"class":533,"line":534},[531,996,997],{"class":545},"{\n",[531,999,1000,1003,1006,1009,1011],{"class":533,"line":651},[531,1001,1002],{"class":545},"  \"",[531,1004,1005],{"class":537},"ai",[531,1007,1008],{"class":545},"\"",[531,1010,566],{"class":545},[531,1012,648],{"class":545},[531,1014,1015,1018,1022,1024,1026,1029],{"class":533,"line":661},[531,1016,1017],{"class":545},"    \"",[531,1019,1021],{"class":1020},"sBMFI","calls",[531,1023,1008],{"class":545},[531,1025,566],{"class":545},[531,1027,1028],{"class":615}," 1",[531,1030,672],{"class":545},[531,1032,1033,1035,1038,1040,1042,1045,1047,1049],{"class":533,"line":675},[531,1034,1017],{"class":545},[531,1036,1037],{"class":1020},"model",[531,1039,1008],{"class":545},[531,1041,566],{"class":545},[531,1043,1044],{"class":545}," \"",[531,1046,892],{"class":721},[531,1048,1008],{"class":545},[531,1050,672],{"class":545},[531,1052,1053,1055,1058,1060,1062,1064,1067,1069],{"class":533,"line":703},[531,1054,1017],{"class":545},[531,1056,1057],{"class":1020},"provider",[531,1059,1008],{"class":545},[531,1061,566],{"class":545},[531,1063,1044],{"class":545},[531,1065,1066],{"class":721},"anthropic",[531,1068,1008],{"class":545},[531,1070,672],{"class":545},[531,1072,1073,1075,1078,1080,1082,1084,1087,1089],{"class":533,"line":751},[531,1074,1017],{"class":545},[531,1076,1077],{"class":1020},"finishReason",[531,1079,1008],{"class":545},[531,1081,566],{"class":545},[531,1083,1044],{"class":545},[531,1085,1086],{"class":721},"error",[531,1088,1008],{"class":545},[531,1090,672],{"class":545},[531,1092,1093,1095,1097,1099,1101,1103,1106],{"class":533,"line":760},[531,1094,1017],{"class":545},[531,1096,1086],{"class":1020},[531,1098,1008],{"class":545},[531,1100,566],{"class":545},[531,1102,1044],{"class":545},[531,1104,1105],{"class":721},"API rate limit exceeded",[531,1107,1108],{"class":545},"\"\n",[531,1110,1111],{"class":533,"line":766},[531,1112,1113],{"class":545},"  }\n",[531,1115,1116],{"class":533,"line":772},[531,1117,1118],{"class":545},"}\n",[408,1120,1121,1122,1125],{},"Stream errors (e.g. content filter) are also captured from the stream's error chunks. Your error-handling code (",[411,1123,1124],{},"try\u002Fcatch",", route-level error handlers) keeps working as usual — the middleware only observes.",[1127,1128,1129],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}",{"title":527,"searchDepth":651,"depth":651,"links":1131},[1132,1137,1138],{"id":488,"depth":651,"text":489,"children":1133},[1134,1135,1136],{"id":519,"depth":661,"text":520},{"id":579,"depth":661,"text":580},{"id":625,"depth":661,"text":626},{"id":843,"depth":651,"text":844},{"id":980,"depth":651,"text":981},"Configure tool input capture (with redaction and truncation), enable cost estimation per model, and handle errors during AI calls.","md",[1142,1145],{"label":41,"icon":44,"to":77,"color":1143,"variant":1144},"neutral","subtle",{"label":1146,"icon":83,"to":81,"color":1143,"variant":1144},"Usage Patterns",{},{"title":85,"icon":88},{"title":85,"description":1139},"wNWYlAoixuzpqUkoMmAWzxK3lYeBu_IxjZhS0DnZOSs",[1152,1154],{"title":80,"path":81,"stem":82,"description":1153,"icon":83,"children":-1},"streamText, generateText, multi-step agents, RAG, and multiple models — every common AI SDK pattern wired into evlog.",{"title":90,"path":91,"stem":92,"description":1155,"icon":93,"children":-1},"Read AI metadata from your handler — persist it, surface it to end-users, bill against it, or stream incremental progress to the client.",1778325967754]