[{"data":1,"prerenderedAt":1146},["ShallowReactive",2],{"navigation_docs":3,"-logging-ai-sdk-options":392,"-logging-ai-sdk-options-surround":1141},[4,35,159,201,289,376],{"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},"Adapters","\u002Fadapters","6.adapters",[294,297,337,352],{"title":41,"path":295,"stem":296,"icon":44},"\u002Fadapters\u002Foverview","6.adapters\u002F01.overview",{"title":298,"path":299,"stem":300,"children":301,"page":34},"Cloud destinations","\u002Fadapters\u002Fcloud","6.adapters\u002F02.cloud",[302,307,312,317,322,327,332],{"title":303,"path":304,"stem":305,"icon":306},"Axiom","\u002Fadapters\u002Fcloud\u002Faxiom","6.adapters\u002F02.cloud\u002F01.axiom","i-custom-axiom",{"title":308,"path":309,"stem":310,"icon":311},"OTLP","\u002Fadapters\u002Fcloud\u002Fotlp","6.adapters\u002F02.cloud\u002F02.otlp","i-simple-icons-opentelemetry",{"title":313,"path":314,"stem":315,"icon":316},"PostHog","\u002Fadapters\u002Fcloud\u002Fposthog","6.adapters\u002F02.cloud\u002F03.posthog","i-simple-icons-posthog",{"title":318,"path":319,"stem":320,"icon":321},"Sentry","\u002Fadapters\u002Fcloud\u002Fsentry","6.adapters\u002F02.cloud\u002F04.sentry","i-simple-icons-sentry",{"title":323,"path":324,"stem":325,"icon":326},"Better Stack","\u002Fadapters\u002Fcloud\u002Fbetter-stack","6.adapters\u002F02.cloud\u002F05.better-stack","i-simple-icons-betterstack",{"title":328,"path":329,"stem":330,"icon":331},"Datadog","\u002Fadapters\u002Fcloud\u002Fdatadog","6.adapters\u002F02.cloud\u002F06.datadog","i-simple-icons-datadog",{"title":333,"path":334,"stem":335,"icon":336},"HyperDX","\u002Fadapters\u002Fcloud\u002Fhyperdx","6.adapters\u002F02.cloud\u002F07.hyperdx","i-custom-hyperdx",{"title":338,"path":339,"stem":340,"children":341,"page":34},"Self-hosted","\u002Fadapters\u002Fself-hosted","6.adapters\u002F03.self-hosted",[342,347],{"title":343,"path":344,"stem":345,"icon":346},"File System","\u002Fadapters\u002Fself-hosted\u002Ffs","6.adapters\u002F03.self-hosted\u002F01.fs","i-lucide-hard-drive",{"title":348,"path":349,"stem":350,"icon":351},"NuxtHub","\u002Fadapters\u002Fself-hosted\u002Fnuxthub","6.adapters\u002F03.self-hosted\u002F02.nuxthub","i-simple-icons-nuxt",{"title":353,"path":354,"stem":355,"children":356,"page":34},"Building blocks","\u002Fadapters\u002Fbuilding-blocks","6.adapters\u002F04.building-blocks",[357,362,367,371],{"title":358,"path":359,"stem":360,"icon":361},"Pipeline","\u002Fadapters\u002Fbuilding-blocks\u002Fpipeline","6.adapters\u002F04.building-blocks\u002F01.pipeline","i-lucide-workflow",{"title":363,"path":364,"stem":365,"icon":366},"HTTP","\u002Fadapters\u002Fbuilding-blocks\u002Fhttp","6.adapters\u002F04.building-blocks\u002F02.http","i-lucide-globe",{"title":368,"path":369,"stem":370,"icon":83},"Custom Adapters","\u002Fadapters\u002Fbuilding-blocks\u002Fcustom","6.adapters\u002F04.building-blocks\u002F03.custom",{"title":372,"path":373,"stem":374,"icon":375},"Toolkit","\u002Fadapters\u002Fbuilding-blocks\u002Ftoolkit","6.adapters\u002F04.building-blocks\u002F04.toolkit","i-lucide-blocks",{"title":377,"path":378,"stem":379,"children":380,"page":34},"Enrichers","\u002Fenrichers","7.enrichers",[381,384,388],{"title":41,"path":382,"stem":383,"icon":28},"\u002Fenrichers\u002Foverview","7.enrichers\u002F1.overview",{"title":385,"path":386,"stem":387,"icon":288},"Built-in","\u002Fenrichers\u002Fbuilt-in","7.enrichers\u002F2.built-in",{"title":389,"path":390,"stem":391,"icon":83},"Custom","\u002Fenrichers\u002Fcustom","7.enrichers\u002F3.custom",{"id":393,"title":85,"body":394,"description":1129,"extension":1130,"links":1131,"meta":1137,"navigation":1138,"path":86,"seo":1139,"stem":87,"__hash__":1140},"docs\u002F2.logging\u002F6.ai-sdk\u002F03.options.md",{"type":395,"value":396,"toc":1120},"minimark",[397,405,475,480,494,506,511,567,571,613,617,768,818,831,835,845,951,961,968,972,975,1109,1116],[398,399,400,404],"p",{},[401,402,403],"code",{},"createAILogger(log, options?)"," accepts a single options bag. Every option is opt-in — defaults stay safe and quiet.",[406,407,408,427],"table",{},[409,410,411],"thead",{},[412,413,414,418,421,424],"tr",{},[415,416,417],"th",{},"Option",[415,419,420],{},"Type",[415,422,423],{},"Default",[415,425,426],{},"Description",[428,429,430,451],"tbody",{},[412,431,432,438,443,448],{},[433,434,435],"td",{},[401,436,437],{},"toolInputs",[433,439,440],{},[401,441,442],{},"boolean | ToolInputsOptions",[433,444,445],{},[401,446,447],{},"false",[433,449,450],{},"Capture tool call inputs alongside their names (off by default to avoid leaking sensitive data).",[412,452,453,458,463,468],{},[433,454,455],{},[401,456,457],{},"cost",[433,459,460],{},[401,461,462],{},"Record\u003Cstring, ModelCost>",[433,464,465],{},[401,466,467],{},"undefined",[433,469,470,471,474],{},"Pricing map. Keys are model IDs, values are ",[401,472,473],{},"{ input, output }"," in dollars per 1M tokens.",[476,477,479],"h2",{"id":478},"tool-inputs","Tool Inputs",[398,481,482,483,486,487,490,491,493],{},"By default, ",[401,484,485],{},"ai.toolCalls"," is a ",[401,488,489],{},"string[]"," of tool names. Enable ",[401,492,437],{}," to capture inputs too — useful for debugging agent behaviour or auditing what data the model reached for.",[495,496,497,498,501,502,505],"warning",{},"Tool inputs can be large and may contain sensitive data (SQL, API keys, customer PII). Use ",[401,499,500],{},"maxLength"," and ",[401,503,504],{},"transform"," rather than enabling raw capture in production.",[507,508,510],"h3",{"id":509},"capture-everything","Capture everything",[512,513,518],"pre",{"className":514,"code":515,"language":516,"meta":517,"style":517},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const ai = createAILogger(log, { toolInputs: true })\n","typescript","",[401,519,520],{"__ignoreMap":517},[521,522,525,529,533,537,541,544,547,550,554,557,561,564],"span",{"class":523,"line":524},"line",1,[521,526,528],{"class":527},"spNyl","const",[521,530,532],{"class":531},"sTEyZ"," ai ",[521,534,536],{"class":535},"sMK4o","=",[521,538,540],{"class":539},"s2Zo4"," createAILogger",[521,542,543],{"class":531},"(log",[521,545,546],{"class":535},",",[521,548,549],{"class":535}," {",[521,551,553],{"class":552},"swJcz"," toolInputs",[521,555,556],{"class":535},":",[521,558,560],{"class":559},"sfNiH"," true",[521,562,563],{"class":535}," }",[521,565,566],{"class":531},")\n",[507,568,570],{"id":569},"truncate-long-inputs","Truncate long inputs",[512,572,574],{"className":514,"code":573,"language":516,"meta":517,"style":517},"const ai = createAILogger(log, { toolInputs: { maxLength: 200 } })\n",[401,575,576],{"__ignoreMap":517},[521,577,578,580,582,584,586,588,590,592,594,596,598,601,603,607,609,611],{"class":523,"line":524},[521,579,528],{"class":527},[521,581,532],{"class":531},[521,583,536],{"class":535},[521,585,540],{"class":539},[521,587,543],{"class":531},[521,589,546],{"class":535},[521,591,549],{"class":535},[521,593,553],{"class":552},[521,595,556],{"class":535},[521,597,549],{"class":535},[521,599,600],{"class":552}," maxLength",[521,602,556],{"class":535},[521,604,606],{"class":605},"sbssI"," 200",[521,608,563],{"class":535},[521,610,563],{"class":535},[521,612,566],{"class":531},[507,614,616],{"id":615},"redact-sensitive-fields","Redact sensitive fields",[512,618,620],{"className":514,"code":619,"language":516,"meta":517,"style":517},"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",[401,621,622,639,649,663,691,739,748,754,760],{"__ignoreMap":517},[521,623,624,626,628,630,632,634,636],{"class":523,"line":524},[521,625,528],{"class":527},[521,627,532],{"class":531},[521,629,536],{"class":535},[521,631,540],{"class":539},[521,633,543],{"class":531},[521,635,546],{"class":535},[521,637,638],{"class":535}," {\n",[521,640,642,645,647],{"class":523,"line":641},2,[521,643,644],{"class":552},"  toolInputs",[521,646,556],{"class":535},[521,648,638],{"class":535},[521,650,652,655,657,660],{"class":523,"line":651},3,[521,653,654],{"class":552},"    maxLength",[521,656,556],{"class":535},[521,658,659],{"class":605}," 500",[521,661,662],{"class":535},",\n",[521,664,666,669,671,674,678,680,683,686,689],{"class":523,"line":665},4,[521,667,668],{"class":539},"    transform",[521,670,556],{"class":535},[521,672,673],{"class":535}," (",[521,675,677],{"class":676},"sHdIc","input",[521,679,546],{"class":535},[521,681,682],{"class":676}," toolName",[521,684,685],{"class":535},")",[521,687,688],{"class":527}," =>",[521,690,638],{"class":535},[521,692,694,698,700,703,706,709,713,716,719,722,724,727,729,731,734,736],{"class":523,"line":693},5,[521,695,697],{"class":696},"s7zQu","      if",[521,699,673],{"class":552},[521,701,702],{"class":531},"toolName",[521,704,705],{"class":535}," ===",[521,707,708],{"class":535}," '",[521,710,712],{"class":711},"sfazB","queryDB",[521,714,715],{"class":535},"'",[521,717,718],{"class":552},") ",[521,720,721],{"class":696},"return",[521,723,549],{"class":535},[521,725,726],{"class":552}," sql",[521,728,556],{"class":535},[521,730,708],{"class":535},[521,732,733],{"class":711},"***",[521,735,715],{"class":535},[521,737,738],{"class":535}," }\n",[521,740,742,745],{"class":523,"line":741},6,[521,743,744],{"class":696},"      return",[521,746,747],{"class":531}," input\n",[521,749,751],{"class":523,"line":750},7,[521,752,753],{"class":535},"    },\n",[521,755,757],{"class":523,"line":756},8,[521,758,759],{"class":535},"  },\n",[521,761,763,766],{"class":523,"line":762},9,[521,764,765],{"class":535},"}",[521,767,566],{"class":531},[406,769,770,781],{},[409,771,772],{},[412,773,774,777,779],{},[415,775,776],{},"Sub-option",[415,778,420],{},[415,780,426],{},[428,782,783,801],{},[412,784,785,789,794],{},[433,786,787],{},[401,788,500],{},[433,790,791],{},[401,792,793],{},"number",[433,795,796,797,800],{},"Truncate stringified inputs exceeding this character length (appends ",[401,798,799],{},"…",").",[412,802,803,807,812],{},[433,804,805],{},[401,806,504],{},[433,808,809],{},[401,810,811],{},"(input, toolName) => unknown",[433,813,814,815,817],{},"Custom transform applied before ",[401,816,500],{},". Use to redact fields or reshape data.",[398,819,820,821,823,824,826,827,830],{},"When ",[401,822,437],{}," is enabled, ",[401,825,485],{}," becomes an ",[401,828,829],{},"Array\u003C{ name, input }>"," instead of a plain string array.",[476,832,834],{"id":833},"cost-estimation","Cost Estimation",[398,836,837,838,840,841,844],{},"Pass a ",[401,839,457],{}," map to compute estimated dollar cost per call. The middleware multiplies token usage by the per-million rates and sets ",[401,842,843],{},"ai.estimatedCost"," on the wide event.",[512,846,848],{"className":514,"code":847,"language":516,"meta":517,"style":517},"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",[401,849,850,866,875,910,941,945],{"__ignoreMap":517},[521,851,852,854,856,858,860,862,864],{"class":523,"line":524},[521,853,528],{"class":527},[521,855,532],{"class":531},[521,857,536],{"class":535},[521,859,540],{"class":539},[521,861,543],{"class":531},[521,863,546],{"class":535},[521,865,638],{"class":535},[521,867,868,871,873],{"class":523,"line":641},[521,869,870],{"class":552},"  cost",[521,872,556],{"class":535},[521,874,638],{"class":535},[521,876,877,880,883,885,887,889,892,894,897,899,902,904,907],{"class":523,"line":651},[521,878,879],{"class":535},"    '",[521,881,882],{"class":552},"claude-sonnet-4.6",[521,884,715],{"class":535},[521,886,556],{"class":535},[521,888,549],{"class":535},[521,890,891],{"class":552}," input",[521,893,556],{"class":535},[521,895,896],{"class":605}," 3",[521,898,546],{"class":535},[521,900,901],{"class":552}," output",[521,903,556],{"class":535},[521,905,906],{"class":605}," 15",[521,908,909],{"class":535}," },\n",[521,911,912,914,917,919,921,923,925,927,930,932,934,936,939],{"class":523,"line":665},[521,913,879],{"class":535},[521,915,916],{"class":552},"gpt-4o",[521,918,715],{"class":535},[521,920,556],{"class":535},[521,922,549],{"class":535},[521,924,891],{"class":552},[521,926,556],{"class":535},[521,928,929],{"class":605}," 2.5",[521,931,546],{"class":535},[521,933,901],{"class":552},[521,935,556],{"class":535},[521,937,938],{"class":605}," 10",[521,940,909],{"class":535},[521,942,943],{"class":523,"line":693},[521,944,759],{"class":535},[521,946,947,949],{"class":523,"line":741},[521,948,765],{"class":535},[521,950,566],{"class":531},[398,952,953,954,960],{},"Read the result from your handler with ",[955,956,957],"a",{"href":91},[401,958,959],{},"ai.getEstimatedCost()"," — useful for billing dashboards or warning users before expensive calls.",[962,963,964,965,967],"tip",{},"Keep your ",[401,966,457],{}," map in one file alongside model selection so renaming a model in production also updates pricing. Avoid hardcoding per-route maps.",[476,969,971],{"id":970},"error-handling","Error Handling",[398,973,974],{},"If a model call fails, the middleware captures the error into the wide event before re-throwing:",[512,976,981],{"className":977,"code":978,"filename":979,"language":980,"meta":517,"style":517},"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",[401,982,983,988,1003,1021,1041,1061,1081,1099,1104],{"__ignoreMap":517},[521,984,985],{"class":523,"line":524},[521,986,987],{"class":535},"{\n",[521,989,990,993,996,999,1001],{"class":523,"line":641},[521,991,992],{"class":535},"  \"",[521,994,995],{"class":527},"ai",[521,997,998],{"class":535},"\"",[521,1000,556],{"class":535},[521,1002,638],{"class":535},[521,1004,1005,1008,1012,1014,1016,1019],{"class":523,"line":651},[521,1006,1007],{"class":535},"    \"",[521,1009,1011],{"class":1010},"sBMFI","calls",[521,1013,998],{"class":535},[521,1015,556],{"class":535},[521,1017,1018],{"class":605}," 1",[521,1020,662],{"class":535},[521,1022,1023,1025,1028,1030,1032,1035,1037,1039],{"class":523,"line":665},[521,1024,1007],{"class":535},[521,1026,1027],{"class":1010},"model",[521,1029,998],{"class":535},[521,1031,556],{"class":535},[521,1033,1034],{"class":535}," \"",[521,1036,882],{"class":711},[521,1038,998],{"class":535},[521,1040,662],{"class":535},[521,1042,1043,1045,1048,1050,1052,1054,1057,1059],{"class":523,"line":693},[521,1044,1007],{"class":535},[521,1046,1047],{"class":1010},"provider",[521,1049,998],{"class":535},[521,1051,556],{"class":535},[521,1053,1034],{"class":535},[521,1055,1056],{"class":711},"anthropic",[521,1058,998],{"class":535},[521,1060,662],{"class":535},[521,1062,1063,1065,1068,1070,1072,1074,1077,1079],{"class":523,"line":741},[521,1064,1007],{"class":535},[521,1066,1067],{"class":1010},"finishReason",[521,1069,998],{"class":535},[521,1071,556],{"class":535},[521,1073,1034],{"class":535},[521,1075,1076],{"class":711},"error",[521,1078,998],{"class":535},[521,1080,662],{"class":535},[521,1082,1083,1085,1087,1089,1091,1093,1096],{"class":523,"line":750},[521,1084,1007],{"class":535},[521,1086,1076],{"class":1010},[521,1088,998],{"class":535},[521,1090,556],{"class":535},[521,1092,1034],{"class":535},[521,1094,1095],{"class":711},"API rate limit exceeded",[521,1097,1098],{"class":535},"\"\n",[521,1100,1101],{"class":523,"line":756},[521,1102,1103],{"class":535},"  }\n",[521,1105,1106],{"class":523,"line":762},[521,1107,1108],{"class":535},"}\n",[398,1110,1111,1112,1115],{},"Stream errors (e.g. content filter) are also captured from the stream's error chunks. Your error-handling code (",[401,1113,1114],{},"try\u002Fcatch",", route-level error handlers) keeps working as usual — the middleware only observes.",[1117,1118,1119],"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":517,"searchDepth":641,"depth":641,"links":1121},[1122,1127,1128],{"id":478,"depth":641,"text":479,"children":1123},[1124,1125,1126],{"id":509,"depth":651,"text":510},{"id":569,"depth":651,"text":570},{"id":615,"depth":651,"text":616},{"id":833,"depth":641,"text":834},{"id":970,"depth":641,"text":971},"Configure tool input capture (with redaction and truncation), enable cost estimation per model, and handle errors during AI calls.","md",[1132,1135],{"label":41,"icon":44,"to":77,"color":1133,"variant":1134},"neutral","subtle",{"label":1136,"icon":83,"to":81,"color":1133,"variant":1134},"Usage Patterns",{},{"title":85,"icon":88},{"title":85,"description":1129},"wNWYlAoixuzpqUkoMmAWzxK3lYeBu_IxjZhS0DnZOSs",[1142,1144],{"title":80,"path":81,"stem":82,"description":1143,"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":1145,"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.",1778106400446]