[{"data":1,"prerenderedAt":1691},["ShallowReactive",2],{"navigation_docs":3,"-logging-ai-sdk-telemetry":388,"-logging-ai-sdk-telemetry-surround":1686},[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":390,"body":391,"description":1674,"extension":1675,"links":1676,"meta":1682,"navigation":1683,"path":91,"seo":1684,"stem":92,"__hash__":1685},"docs\u002F2.logging\u002F5.ai-sdk\u002F05.telemetry.md","Deeper Telemetry",{"type":392,"value":393,"toc":1668},"minimark",[394,410,415,426,756,759,1127,1131,1134,1254,1258,1327,1330,1334,1342,1519,1529,1643,1664],[395,396,397,401,402,405,406,409],"p",{},[398,399,400],"code",{},"createAILogger"," covers tokens, model info, and streaming metrics. For deeper observability — per-tool execution timing, success\u002Ffailure tracking, and total generation wall time — add ",[398,403,404],{},"createEvlogIntegration()"," on top. It implements the AI SDK's ",[398,407,408],{},"TelemetryIntegration"," interface and captures data middleware alone cannot see.",[411,412,414],"h2",{"id":413},"combined-with-middleware-recommended","Combined with middleware (recommended)",[395,416,417,418,421,422,425],{},"When passed an ",[398,419,420],{},"AILogger",", the integration shares its accumulator. Both paths write to the same ",[398,423,424],{},"ai.*"," field:",[427,428,434],"pre",{"className":429,"code":430,"filename":431,"language":432,"meta":433,"style":433},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { generateText } from 'ai'\nimport { createAILogger, createEvlogIntegration } from 'evlog\u002Fai'\n\nexport default defineEventHandler(async (event) => {\n  const log = useLogger(event)\n  const ai = createAILogger(log)\n\n  const result = await generateText({\n    model: ai.wrap('anthropic\u002Fclaude-sonnet-4.6'),\n    tools: { getWeather, searchDB },\n    experimental_telemetry: {\n      isEnabled: true,\n      integrations: [createEvlogIntegration(ai)],\n    },\n  })\n\n  return { text: result.text }\n})\n","server\u002Fapi\u002Fagent.post.ts","typescript","",[398,435,436,469,496,503,539,562,581,586,606,638,659,669,683,706,712,720,725,748],{"__ignoreMap":433},[437,438,441,445,449,453,456,459,462,466],"span",{"class":439,"line":440},"line",1,[437,442,444],{"class":443},"s7zQu","import",[437,446,448],{"class":447},"sMK4o"," {",[437,450,452],{"class":451},"sTEyZ"," generateText",[437,454,455],{"class":447}," }",[437,457,458],{"class":443}," from",[437,460,461],{"class":447}," '",[437,463,465],{"class":464},"sfazB","ai",[437,467,468],{"class":447},"'\n",[437,470,472,474,476,479,482,485,487,489,491,494],{"class":439,"line":471},2,[437,473,444],{"class":443},[437,475,448],{"class":447},[437,477,478],{"class":451}," createAILogger",[437,480,481],{"class":447},",",[437,483,484],{"class":451}," createEvlogIntegration",[437,486,455],{"class":447},[437,488,458],{"class":443},[437,490,461],{"class":447},[437,492,493],{"class":464},"evlog\u002Fai",[437,495,468],{"class":447},[437,497,499],{"class":439,"line":498},3,[437,500,502],{"emptyLinePlaceholder":501},true,"\n",[437,504,506,509,512,516,519,523,526,530,533,536],{"class":439,"line":505},4,[437,507,508],{"class":443},"export",[437,510,511],{"class":443}," default",[437,513,515],{"class":514},"s2Zo4"," defineEventHandler",[437,517,518],{"class":451},"(",[437,520,522],{"class":521},"spNyl","async",[437,524,525],{"class":447}," (",[437,527,529],{"class":528},"sHdIc","event",[437,531,532],{"class":447},")",[437,534,535],{"class":521}," =>",[437,537,538],{"class":447}," {\n",[437,540,542,545,548,551,554,557,559],{"class":439,"line":541},5,[437,543,544],{"class":521},"  const",[437,546,547],{"class":451}," log",[437,549,550],{"class":447}," =",[437,552,553],{"class":514}," useLogger",[437,555,518],{"class":556},"swJcz",[437,558,529],{"class":451},[437,560,561],{"class":556},")\n",[437,563,565,567,570,572,574,576,579],{"class":439,"line":564},6,[437,566,544],{"class":521},[437,568,569],{"class":451}," ai",[437,571,550],{"class":447},[437,573,478],{"class":514},[437,575,518],{"class":556},[437,577,578],{"class":451},"log",[437,580,561],{"class":556},[437,582,584],{"class":439,"line":583},7,[437,585,502],{"emptyLinePlaceholder":501},[437,587,589,591,594,596,599,601,603],{"class":439,"line":588},8,[437,590,544],{"class":521},[437,592,593],{"class":451}," result",[437,595,550],{"class":447},[437,597,598],{"class":443}," await",[437,600,452],{"class":514},[437,602,518],{"class":556},[437,604,605],{"class":447},"{\n",[437,607,609,612,615,617,620,623,625,628,631,633,635],{"class":439,"line":608},9,[437,610,611],{"class":556},"    model",[437,613,614],{"class":447},":",[437,616,569],{"class":451},[437,618,619],{"class":447},".",[437,621,622],{"class":514},"wrap",[437,624,518],{"class":556},[437,626,627],{"class":447},"'",[437,629,630],{"class":464},"anthropic\u002Fclaude-sonnet-4.6",[437,632,627],{"class":447},[437,634,532],{"class":556},[437,636,637],{"class":447},",\n",[437,639,641,644,646,648,651,653,656],{"class":439,"line":640},10,[437,642,643],{"class":556},"    tools",[437,645,614],{"class":447},[437,647,448],{"class":447},[437,649,650],{"class":451}," getWeather",[437,652,481],{"class":447},[437,654,655],{"class":451}," searchDB",[437,657,658],{"class":447}," },\n",[437,660,662,665,667],{"class":439,"line":661},11,[437,663,664],{"class":556},"    experimental_telemetry",[437,666,614],{"class":447},[437,668,538],{"class":447},[437,670,672,675,677,681],{"class":439,"line":671},12,[437,673,674],{"class":556},"      isEnabled",[437,676,614],{"class":447},[437,678,680],{"class":679},"sfNiH"," true",[437,682,637],{"class":447},[437,684,686,689,691,694,697,699,701,704],{"class":439,"line":685},13,[437,687,688],{"class":556},"      integrations",[437,690,614],{"class":447},[437,692,693],{"class":556}," [",[437,695,696],{"class":514},"createEvlogIntegration",[437,698,518],{"class":556},[437,700,465],{"class":451},[437,702,703],{"class":556},")]",[437,705,637],{"class":447},[437,707,709],{"class":439,"line":708},14,[437,710,711],{"class":447},"    },\n",[437,713,715,718],{"class":439,"line":714},15,[437,716,717],{"class":447},"  }",[437,719,561],{"class":556},[437,721,723],{"class":439,"line":722},16,[437,724,502],{"emptyLinePlaceholder":501},[437,726,728,731,733,736,738,740,742,745],{"class":439,"line":727},17,[437,729,730],{"class":443},"  return",[437,732,448],{"class":447},[437,734,735],{"class":556}," text",[437,737,614],{"class":447},[437,739,593],{"class":451},[437,741,619],{"class":447},[437,743,744],{"class":451},"text",[437,746,747],{"class":447}," }\n",[437,749,751,754],{"class":439,"line":750},18,[437,752,753],{"class":447},"}",[437,755,561],{"class":451},[395,757,758],{},"Your wide event now includes per-tool timing:",[427,760,765],{"className":761,"code":762,"filename":763,"language":764,"meta":433,"style":433},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"ai\": {\n    \"calls\": 2,\n    \"steps\": 2,\n    \"model\": \"claude-sonnet-4.6\",\n    \"provider\": \"anthropic\",\n    \"inputTokens\": 3500,\n    \"outputTokens\": 800,\n    \"totalTokens\": 4300,\n    \"toolCalls\": [\"getWeather\", \"searchDB\"],\n    \"tools\": [\n      { \"name\": \"getWeather\", \"durationMs\": 150, \"success\": true },\n      { \"name\": \"searchDB\", \"durationMs\": 45, \"success\": true }\n    ],\n    \"totalDurationMs\": 2340,\n    \"msToFirstChunk\": 180,\n    \"msToFinish\": 2100,\n    \"tokensPerSecond\": 380\n  }\n}\n","Wide Event","json",[398,766,767,771,785,804,819,840,860,876,892,908,940,954,1003,1048,1053,1069,1085,1101,1115,1121],{"__ignoreMap":433},[437,768,769],{"class":439,"line":440},[437,770,605],{"class":447},[437,772,773,776,778,781,783],{"class":439,"line":471},[437,774,775],{"class":447},"  \"",[437,777,465],{"class":521},[437,779,780],{"class":447},"\"",[437,782,614],{"class":447},[437,784,538],{"class":447},[437,786,787,790,794,796,798,802],{"class":439,"line":498},[437,788,789],{"class":447},"    \"",[437,791,793],{"class":792},"sBMFI","calls",[437,795,780],{"class":447},[437,797,614],{"class":447},[437,799,801],{"class":800},"sbssI"," 2",[437,803,637],{"class":447},[437,805,806,808,811,813,815,817],{"class":439,"line":505},[437,807,789],{"class":447},[437,809,810],{"class":792},"steps",[437,812,780],{"class":447},[437,814,614],{"class":447},[437,816,801],{"class":800},[437,818,637],{"class":447},[437,820,821,823,826,828,830,833,836,838],{"class":439,"line":541},[437,822,789],{"class":447},[437,824,825],{"class":792},"model",[437,827,780],{"class":447},[437,829,614],{"class":447},[437,831,832],{"class":447}," \"",[437,834,835],{"class":464},"claude-sonnet-4.6",[437,837,780],{"class":447},[437,839,637],{"class":447},[437,841,842,844,847,849,851,853,856,858],{"class":439,"line":564},[437,843,789],{"class":447},[437,845,846],{"class":792},"provider",[437,848,780],{"class":447},[437,850,614],{"class":447},[437,852,832],{"class":447},[437,854,855],{"class":464},"anthropic",[437,857,780],{"class":447},[437,859,637],{"class":447},[437,861,862,864,867,869,871,874],{"class":439,"line":583},[437,863,789],{"class":447},[437,865,866],{"class":792},"inputTokens",[437,868,780],{"class":447},[437,870,614],{"class":447},[437,872,873],{"class":800}," 3500",[437,875,637],{"class":447},[437,877,878,880,883,885,887,890],{"class":439,"line":588},[437,879,789],{"class":447},[437,881,882],{"class":792},"outputTokens",[437,884,780],{"class":447},[437,886,614],{"class":447},[437,888,889],{"class":800}," 800",[437,891,637],{"class":447},[437,893,894,896,899,901,903,906],{"class":439,"line":608},[437,895,789],{"class":447},[437,897,898],{"class":792},"totalTokens",[437,900,780],{"class":447},[437,902,614],{"class":447},[437,904,905],{"class":800}," 4300",[437,907,637],{"class":447},[437,909,910,912,915,917,919,921,923,926,928,930,932,935,937],{"class":439,"line":640},[437,911,789],{"class":447},[437,913,914],{"class":792},"toolCalls",[437,916,780],{"class":447},[437,918,614],{"class":447},[437,920,693],{"class":447},[437,922,780],{"class":447},[437,924,925],{"class":464},"getWeather",[437,927,780],{"class":447},[437,929,481],{"class":447},[437,931,832],{"class":447},[437,933,934],{"class":464},"searchDB",[437,936,780],{"class":447},[437,938,939],{"class":447},"],\n",[437,941,942,944,947,949,951],{"class":439,"line":661},[437,943,789],{"class":447},[437,945,946],{"class":792},"tools",[437,948,780],{"class":447},[437,950,614],{"class":447},[437,952,953],{"class":447}," [\n",[437,955,956,959,961,964,966,968,970,972,974,976,978,981,983,985,988,990,992,995,997,999,1001],{"class":439,"line":671},[437,957,958],{"class":447},"      {",[437,960,832],{"class":447},[437,962,963],{"class":800},"name",[437,965,780],{"class":447},[437,967,614],{"class":447},[437,969,832],{"class":447},[437,971,925],{"class":464},[437,973,780],{"class":447},[437,975,481],{"class":447},[437,977,832],{"class":447},[437,979,980],{"class":800},"durationMs",[437,982,780],{"class":447},[437,984,614],{"class":447},[437,986,987],{"class":800}," 150",[437,989,481],{"class":447},[437,991,832],{"class":447},[437,993,994],{"class":800},"success",[437,996,780],{"class":447},[437,998,614],{"class":447},[437,1000,680],{"class":447},[437,1002,658],{"class":447},[437,1004,1005,1007,1009,1011,1013,1015,1017,1019,1021,1023,1025,1027,1029,1031,1034,1036,1038,1040,1042,1044,1046],{"class":439,"line":685},[437,1006,958],{"class":447},[437,1008,832],{"class":447},[437,1010,963],{"class":800},[437,1012,780],{"class":447},[437,1014,614],{"class":447},[437,1016,832],{"class":447},[437,1018,934],{"class":464},[437,1020,780],{"class":447},[437,1022,481],{"class":447},[437,1024,832],{"class":447},[437,1026,980],{"class":800},[437,1028,780],{"class":447},[437,1030,614],{"class":447},[437,1032,1033],{"class":800}," 45",[437,1035,481],{"class":447},[437,1037,832],{"class":447},[437,1039,994],{"class":800},[437,1041,780],{"class":447},[437,1043,614],{"class":447},[437,1045,680],{"class":447},[437,1047,747],{"class":447},[437,1049,1050],{"class":439,"line":708},[437,1051,1052],{"class":447},"    ],\n",[437,1054,1055,1057,1060,1062,1064,1067],{"class":439,"line":714},[437,1056,789],{"class":447},[437,1058,1059],{"class":792},"totalDurationMs",[437,1061,780],{"class":447},[437,1063,614],{"class":447},[437,1065,1066],{"class":800}," 2340",[437,1068,637],{"class":447},[437,1070,1071,1073,1076,1078,1080,1083],{"class":439,"line":722},[437,1072,789],{"class":447},[437,1074,1075],{"class":792},"msToFirstChunk",[437,1077,780],{"class":447},[437,1079,614],{"class":447},[437,1081,1082],{"class":800}," 180",[437,1084,637],{"class":447},[437,1086,1087,1089,1092,1094,1096,1099],{"class":439,"line":727},[437,1088,789],{"class":447},[437,1090,1091],{"class":792},"msToFinish",[437,1093,780],{"class":447},[437,1095,614],{"class":447},[437,1097,1098],{"class":800}," 2100",[437,1100,637],{"class":447},[437,1102,1103,1105,1108,1110,1112],{"class":439,"line":750},[437,1104,789],{"class":447},[437,1106,1107],{"class":792},"tokensPerSecond",[437,1109,780],{"class":447},[437,1111,614],{"class":447},[437,1113,1114],{"class":800}," 380\n",[437,1116,1118],{"class":439,"line":1117},19,[437,1119,1120],{"class":447},"  }\n",[437,1122,1124],{"class":439,"line":1123},20,[437,1125,1126],{"class":447},"}\n",[411,1128,1130],{"id":1129},"standalone-without-middleware","Standalone (without middleware)",[395,1132,1133],{},"If your model is already wrapped (e.g. by another middleware), pass the request logger directly:",[427,1135,1138],{"className":429,"code":1136,"filename":1137,"language":432,"meta":433,"style":433},"import { createEvlogIntegration } from 'evlog\u002Fai'\n\nconst integration = createEvlogIntegration(log)\n\nconst result = await generateText({\n  model: somePreWrappedModel,\n  experimental_telemetry: {\n    isEnabled: true,\n    integrations: [integration],\n  },\n})\n","server\u002Fapi\u002Fchat.post.ts",[398,1139,1140,1158,1162,1178,1182,1199,1211,1220,1231,1243,1248],{"__ignoreMap":433},[437,1141,1142,1144,1146,1148,1150,1152,1154,1156],{"class":439,"line":440},[437,1143,444],{"class":443},[437,1145,448],{"class":447},[437,1147,484],{"class":451},[437,1149,455],{"class":447},[437,1151,458],{"class":443},[437,1153,461],{"class":447},[437,1155,493],{"class":464},[437,1157,468],{"class":447},[437,1159,1160],{"class":439,"line":471},[437,1161,502],{"emptyLinePlaceholder":501},[437,1163,1164,1167,1170,1173,1175],{"class":439,"line":498},[437,1165,1166],{"class":521},"const",[437,1168,1169],{"class":451}," integration ",[437,1171,1172],{"class":447},"=",[437,1174,484],{"class":514},[437,1176,1177],{"class":451},"(log)\n",[437,1179,1180],{"class":439,"line":505},[437,1181,502],{"emptyLinePlaceholder":501},[437,1183,1184,1186,1189,1191,1193,1195,1197],{"class":439,"line":541},[437,1185,1166],{"class":521},[437,1187,1188],{"class":451}," result ",[437,1190,1172],{"class":447},[437,1192,598],{"class":443},[437,1194,452],{"class":514},[437,1196,518],{"class":451},[437,1198,605],{"class":447},[437,1200,1201,1204,1206,1209],{"class":439,"line":564},[437,1202,1203],{"class":556},"  model",[437,1205,614],{"class":447},[437,1207,1208],{"class":451}," somePreWrappedModel",[437,1210,637],{"class":447},[437,1212,1213,1216,1218],{"class":439,"line":583},[437,1214,1215],{"class":556},"  experimental_telemetry",[437,1217,614],{"class":447},[437,1219,538],{"class":447},[437,1221,1222,1225,1227,1229],{"class":439,"line":588},[437,1223,1224],{"class":556},"    isEnabled",[437,1226,614],{"class":447},[437,1228,680],{"class":679},[437,1230,637],{"class":447},[437,1232,1233,1236,1238,1241],{"class":439,"line":608},[437,1234,1235],{"class":556},"    integrations",[437,1237,614],{"class":447},[437,1239,1240],{"class":451}," [integration]",[437,1242,637],{"class":447},[437,1244,1245],{"class":439,"line":640},[437,1246,1247],{"class":447},"  },\n",[437,1249,1250,1252],{"class":439,"line":661},[437,1251,753],{"class":447},[437,1253,561],{"class":451},[411,1255,1257],{"id":1256},"what-the-integration-captures","What the integration captures",[1259,1260,1261,1277],"table",{},[1262,1263,1264],"thead",{},[1265,1266,1267,1271,1274],"tr",{},[1268,1269,1270],"th",{},"Data",[1268,1272,1273],{},"Source",[1268,1275,1276],{},"Description",[1278,1279,1280,1308],"tbody",{},[1265,1281,1282,1288,1293],{},[1283,1284,1285],"td",{},[398,1286,1287],{},"ai.tools[]",[1283,1289,1290],{},[398,1291,1292],{},"onToolCallFinish",[1283,1294,1295,1296,1298,1299,1298,1301,1303,1304,1307],{},"Per-tool ",[398,1297,963],{},", ",[398,1300,980],{},[398,1302,994],{},", and ",[398,1305,1306],{},"error"," (if failed)",[1265,1309,1310,1315,1324],{},[1283,1311,1312],{},[398,1313,1314],{},"ai.totalDurationMs",[1283,1316,1317,1320,1321],{},[398,1318,1319],{},"onStart"," → ",[398,1322,1323],{},"onFinish",[1283,1325,1326],{},"Total wall time from generation start to completion",[395,1328,1329],{},"The middleware captures tokens, model info, and streaming metrics. The integration captures tool execution timing. Together, they give you complete AI observability.",[411,1331,1333],{"id":1332},"composability","Composability",[395,1335,1336,1339,1340,614],{},[398,1337,1338],{},"ai.wrap()"," works with models that are already wrapped by other tools. If you use supermemory, guardrails middleware, or any other model wrapper, pass the wrapped model to ",[398,1341,1338],{},[427,1343,1345],{"className":429,"code":1344,"filename":1137,"language":432,"meta":433,"style":433},"import { createAILogger } from 'evlog\u002Fai'\nimport { withSupermemory } from '@supermemory\u002Ftools\u002Fai-sdk'\nimport { createGateway } from 'ai'\n\nconst gateway = createGateway({ ... })\nconst ai = createAILogger(log)\nconst base = gateway('anthropic\u002Fclaude-sonnet-4.6')\nconst model = ai.wrap(withSupermemory(base, 'your-org-id', { mode: 'full' }))\n",[398,1346,1347,1365,1385,1404,1408,1431,1444,1466],{"__ignoreMap":433},[437,1348,1349,1351,1353,1355,1357,1359,1361,1363],{"class":439,"line":440},[437,1350,444],{"class":443},[437,1352,448],{"class":447},[437,1354,478],{"class":451},[437,1356,455],{"class":447},[437,1358,458],{"class":443},[437,1360,461],{"class":447},[437,1362,493],{"class":464},[437,1364,468],{"class":447},[437,1366,1367,1369,1371,1374,1376,1378,1380,1383],{"class":439,"line":471},[437,1368,444],{"class":443},[437,1370,448],{"class":447},[437,1372,1373],{"class":451}," withSupermemory",[437,1375,455],{"class":447},[437,1377,458],{"class":443},[437,1379,461],{"class":447},[437,1381,1382],{"class":464},"@supermemory\u002Ftools\u002Fai-sdk",[437,1384,468],{"class":447},[437,1386,1387,1389,1391,1394,1396,1398,1400,1402],{"class":439,"line":498},[437,1388,444],{"class":443},[437,1390,448],{"class":447},[437,1392,1393],{"class":451}," createGateway",[437,1395,455],{"class":447},[437,1397,458],{"class":443},[437,1399,461],{"class":447},[437,1401,465],{"class":464},[437,1403,468],{"class":447},[437,1405,1406],{"class":439,"line":505},[437,1407,502],{"emptyLinePlaceholder":501},[437,1409,1410,1412,1415,1417,1419,1421,1424,1427,1429],{"class":439,"line":541},[437,1411,1166],{"class":521},[437,1413,1414],{"class":451}," gateway ",[437,1416,1172],{"class":447},[437,1418,1393],{"class":514},[437,1420,518],{"class":451},[437,1422,1423],{"class":447},"{",[437,1425,1426],{"class":447}," ...",[437,1428,455],{"class":447},[437,1430,561],{"class":451},[437,1432,1433,1435,1438,1440,1442],{"class":439,"line":564},[437,1434,1166],{"class":521},[437,1436,1437],{"class":451}," ai ",[437,1439,1172],{"class":447},[437,1441,478],{"class":514},[437,1443,1177],{"class":451},[437,1445,1446,1448,1451,1453,1456,1458,1460,1462,1464],{"class":439,"line":583},[437,1447,1166],{"class":521},[437,1449,1450],{"class":451}," base ",[437,1452,1172],{"class":447},[437,1454,1455],{"class":514}," gateway",[437,1457,518],{"class":451},[437,1459,627],{"class":447},[437,1461,630],{"class":464},[437,1463,627],{"class":447},[437,1465,561],{"class":451},[437,1467,1468,1470,1473,1475,1477,1479,1481,1483,1486,1489,1491,1493,1496,1498,1500,1502,1505,1507,1509,1512,1514,1516],{"class":439,"line":588},[437,1469,1166],{"class":521},[437,1471,1472],{"class":451}," model ",[437,1474,1172],{"class":447},[437,1476,569],{"class":451},[437,1478,619],{"class":447},[437,1480,622],{"class":514},[437,1482,518],{"class":451},[437,1484,1485],{"class":514},"withSupermemory",[437,1487,1488],{"class":451},"(base",[437,1490,481],{"class":447},[437,1492,461],{"class":447},[437,1494,1495],{"class":464},"your-org-id",[437,1497,627],{"class":447},[437,1499,481],{"class":447},[437,1501,448],{"class":447},[437,1503,1504],{"class":556}," mode",[437,1506,614],{"class":447},[437,1508,461],{"class":447},[437,1510,1511],{"class":464},"full",[437,1513,627],{"class":447},[437,1515,455],{"class":447},[437,1517,1518],{"class":451},"))\n",[395,1520,1521,1522,1525,1526,614],{},"For explicit middleware composition, use ",[398,1523,1524],{},"createAIMiddleware"," to get the raw middleware and compose it yourself via ",[398,1527,1528],{},"wrapLanguageModel",[427,1530,1532],{"className":429,"code":1531,"filename":1137,"language":432,"meta":433,"style":433},"import { createAIMiddleware } from 'evlog\u002Fai'\nimport { wrapLanguageModel } from 'ai'\n\nconst model = wrapLanguageModel({\n  model: base,\n  middleware: [createAIMiddleware(log, { toolInputs: true }), otherMiddleware],\n})\n",[398,1533,1534,1553,1572,1576,1590,1601,1637],{"__ignoreMap":433},[437,1535,1536,1538,1540,1543,1545,1547,1549,1551],{"class":439,"line":440},[437,1537,444],{"class":443},[437,1539,448],{"class":447},[437,1541,1542],{"class":451}," createAIMiddleware",[437,1544,455],{"class":447},[437,1546,458],{"class":443},[437,1548,461],{"class":447},[437,1550,493],{"class":464},[437,1552,468],{"class":447},[437,1554,1555,1557,1559,1562,1564,1566,1568,1570],{"class":439,"line":471},[437,1556,444],{"class":443},[437,1558,448],{"class":447},[437,1560,1561],{"class":451}," wrapLanguageModel",[437,1563,455],{"class":447},[437,1565,458],{"class":443},[437,1567,461],{"class":447},[437,1569,465],{"class":464},[437,1571,468],{"class":447},[437,1573,1574],{"class":439,"line":498},[437,1575,502],{"emptyLinePlaceholder":501},[437,1577,1578,1580,1582,1584,1586,1588],{"class":439,"line":505},[437,1579,1166],{"class":521},[437,1581,1472],{"class":451},[437,1583,1172],{"class":447},[437,1585,1561],{"class":514},[437,1587,518],{"class":451},[437,1589,605],{"class":447},[437,1591,1592,1594,1596,1599],{"class":439,"line":541},[437,1593,1203],{"class":556},[437,1595,614],{"class":447},[437,1597,1598],{"class":451}," base",[437,1600,637],{"class":447},[437,1602,1603,1606,1608,1610,1612,1615,1617,1619,1622,1624,1626,1628,1630,1632,1635],{"class":439,"line":564},[437,1604,1605],{"class":556},"  middleware",[437,1607,614],{"class":447},[437,1609,693],{"class":451},[437,1611,1524],{"class":514},[437,1613,1614],{"class":451},"(log",[437,1616,481],{"class":447},[437,1618,448],{"class":447},[437,1620,1621],{"class":556}," toolInputs",[437,1623,614],{"class":447},[437,1625,680],{"class":679},[437,1627,455],{"class":447},[437,1629,532],{"class":451},[437,1631,481],{"class":447},[437,1633,1634],{"class":451}," otherMiddleware]",[437,1636,637],{"class":447},[437,1638,1639,1641],{"class":439,"line":583},[437,1640,753],{"class":447},[437,1642,561],{"class":451},[395,1644,1645,1647,1648,1650,1651,1653,1654,1657,1658,1660,1661,1663],{},[398,1646,1524],{}," returns the same middleware that ",[398,1649,400],{}," uses internally. The difference: ",[398,1652,1524],{}," does not include ",[398,1655,1656],{},"captureEmbed"," (embedding models don't use middleware). Use ",[398,1659,400],{}," for the full API, ",[398,1662,1524],{}," when you need explicit middleware ordering.",[1665,1666,1667],"style",{},"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 .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}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 .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 .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}",{"title":433,"searchDepth":471,"depth":471,"links":1669},[1670,1671,1672,1673],{"id":413,"depth":471,"text":414},{"id":1129,"depth":471,"text":1130},{"id":1256,"depth":471,"text":1257},{"id":1332,"depth":471,"text":1333},"Add tool execution timing and total wall time with createEvlogIntegration. Compose with other middleware like supermemory or guardrails.","md",[1677,1680],{"label":41,"icon":44,"to":72,"color":1678,"variant":1679},"neutral","subtle",{"label":1681,"icon":78,"to":76,"color":1678,"variant":1679},"Usage Patterns",{},{"title":90,"icon":93},{"title":390,"description":1674},"DEvWDvYBDMrJzwd5aA3HFJWDN5siDkKkPl35AclAT8w",[1687,1689],{"title":85,"path":86,"stem":87,"description":1688,"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.",{"title":41,"path":101,"stem":102,"description":1690,"icon":44,"children":-1},"Automatically identify users on every request. Every wide event includes who made the request — userId, user profile, and session metadata — with zero manual work.",1777982709005]