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