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