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