Contents

posthog-ai

8.22.1

Patch Changes

  • #5860 4288b33 Thanks @utsxvrai! - Keep the choices of an n > 1 streamed OpenAI chat completion apart in $ai_output_choices, one message per choice as non-streamed calls already do, and take $ai_stop_reason from the first choice. (2026-11-25)

8.22.0

Minor Changes

  • #5835 6e58c08 Thanks @Radu-Raicea! - Read revisions, correct scores, and update or delete accepted offline evaluation items, results, and payloads. (2026-11-20)

8.21.1

Patch Changes

  • #5764 93a47d8 Thanks @pcbeingused333! - fix(ai): stop logging a parse error for streamed Anthropic tool calls that take no arguments (2026-11-18)

8.21.0

Minor Changes

  • #5407 6405dfd Thanks @eli-r-ph! - With posthog-node 6.x.x, every AI event is sent through captureAi on the capture v1 AI lane, and enableFullAiCapture only controls truncation and media redaction. With posthog-node 5.x.x, nothing changes: AI events use capture unless enableFullAiCapture is set. (2026-11-17)

  • #5407 6405dfd Thanks @eli-r-ph! - Add per-event options for posthog-node: posthogOptions on wrapped provider calls and withTracing(), and options on the LangChain, OpenAI Agents, Claude Agent SDK, Google ADK and Genkit integrations. An event with no distinct id still has person processing turned off. On posthog-node 6.x.x, AI events carry person processing only as the process_person_profile option. On posthog-node 5.x.x, each option that version knows is sent in the form it reads, and other keys are dropped. OpenAI Agents instrument() now passes every processor option, including options and onError, to the processor it registers. (2026-11-17)

Patch Changes

  • #5407 6405dfd Thanks @eli-r-ph! - Genkit spans and @posthog/mcp events with no user distinct id set the process_person_profile: false event option on posthog-node 6.x.x, so a registered or context process_person_profile: true option no longer creates a person for each trace or session. Genkit also counts an empty or whitespace-only distinct id as missing. (2026-11-17)

  • #5407 6405dfd Thanks @eli-r-ph! - Export the table of per-event options and the event properties posthog-node 5.x.x reads instead, so posthog-node, @posthog/ai and @posthog/mcp share one copy. (2026-11-17)

  • #5407 6405dfd Thanks @eli-r-ph! - @posthog/ai now recognizes posthog-node 6.x.x by its registerOptions method instead of by getLibraryVersion(). A posthog-node 6.x.x client whose version a wrapper or subclass overrides, for example @posthog/mcp, no longer sends its AI events to the analytics endpoint. posthog-node 5.x.x clients still use capture() unless enableFullAiCapture is on. (2026-11-17)

  • #5407 6405dfd Thanks @eli-r-ph! - Supports posthog-node 6.x.x. Exception autocapture passes an options object to captureException when the client is posthog-node 6.x.x, and positional arguments for posthog-node 5.x.x. (2026-11-17)

  • #5407 6405dfd Thanks @eli-r-ph! - An AI event with no user distinct id now also sets the process_person_profile: false event option, so with posthog-node 6.x.x it stays personless even when a context or registered option turns person processing on. An empty or whitespace-only distinct id now counts as missing in every integration, so the event uses the trace or run id and stays personless. (2026-11-17)

  • Updated dependencies [6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd, 6405dfd]:

8.20.2

Patch Changes

  • #5533 50197f0 Thanks @yoarajota! - Keep an object that appears twice in the input of a captured AI generation. The second occurrence was replaced with null. (2026-11-16)

8.20.1

Patch Changes

  • #5728 74013ba Thanks @mindulle! - Widen the supported @anthropic-ai/sdk peer range to >=0.112.3 <2.0.0 and @google/genai to ^1.52.0 || ^2.18.0 || ^3.0.0 to support current SDK majors. (2026-11-16)

8.20.0

Minor Changes

  • #5678 22d5e11 Thanks @Radu-Raicea! - Support versioned composite scorers, formula validation, and dependency-safe offline evaluation uploads. (2026-11-12)

8.19.3

Patch Changes

  • #5691 3e62421 Thanks @shehjaddev! - Streamed OpenAI chat completions now keep custom tool calls in $ai_output_choices, the same way non-streaming completions do. (2026-11-12)

8.19.2

Patch Changes

  • #5604 a516cf3 Thanks @smitp1402! - Capture reasoning tokens from OpenAI Agents SDK Responses API spans in $ai_reasoning_tokens (2026-11-10)

  • #5622 7d96fa3 Thanks @pcbeingused333! - Capture custom tool calls in OpenAI Responses API output. (2026-11-10)

8.19.1

Patch Changes

8.19.0

Minor Changes

  • #5625 a93bee2 Thanks @tokerson! - Support openai 7 alongside 6, and type embeddings.create with encoding_format: 'base64' as returning base64 strings. (2026-11-09)

8.18.6

Patch Changes

  • #5609 eb11f00 Thanks @pcbeingused333! - Report $ai_reasoning_tokens for Anthropic calls from usage.output_tokens_details.thinking_tokens, in the wrapper (streaming and non-streaming) and in the Claude Agent SDK processor. (2026-11-09)

8.18.5

Patch Changes

  • #5556 b63702f Thanks @eli-r-ph! - Genkit: redact credentials in model messages, so a credential that a tool returns no longer reaches $ai_input. (2026-11-05)

8.18.4

Patch Changes

  • #5563 b1bbf31 Thanks @pcbeingused333! - Keep the refusal text of OpenAI Responses API outputs instead of dropping it from the captured $ai_output_choices (2026-11-05)

  • #5555 a129e9f Thanks @smitp1402! - Count Gemini Interactions tool-use tokens in the captured input tokens. (2026-11-05)

8.18.3

Patch Changes

  • #5530 9909fee Thanks @marandaneto! - Fix loading and constructing the OpenTelemetry span processor in bundled Cloudflare Workers. (2026-11-03)

8.18.2

Patch Changes

  • #5520 af74347 Thanks @bernatixer! - Vercel AI SDK file capture: keep provider file IDs like file-abc123 as they are instead of turning them into data URLs, use the same placeholder for an over-budget file however it was passed, and skip encoding output files in privacy mode (2026-11-02)
  • Updated dependencies [3fbb667]:

8.18.1

Patch Changes

  • #5496 3611fd2 Thanks @bernatixer! - Capture Vercel AI SDK file parts passed as bytes instead of recording "raw files not supported" (2026-11-02)

8.18.0

Minor Changes

  • #5381 bac61c2 Thanks @Brian-1812! - Add a Genkit integration that captures flows, model calls, embedder calls and tool calls as AI observability events (2026-11-02)

8.17.2

Patch Changes

  • #5439 a22cbec Thanks @posthog! - Fix @posthog/ai/otel so that it loads with OpenTelemetry JS 3.x, which has no @opentelemetry/sdk-trace-base. (2026-10-29)

8.17.1

Patch Changes

  • #5478 aa4ed5d Thanks @pcbeingused333! - Capture an $ai_generation error event when an OpenAI, Azure OpenAI or Anthropic call with stream: true fails before the stream opens (for example a 401, 429 or invalid model). Before, only the non-streaming call captured those errors. (2026-10-29)

8.17.0

Minor Changes

  • #5438 acdbdd2 Thanks @Radu-Raicea! - Add per-item model attribution to offline evaluations and dataset execution conversion. (2026-10-26)

8.16.3

Patch Changes

8.16.2

Patch Changes

8.16.1

Patch Changes

  • #5355 e027825 Thanks @pcbeingused333! - Capture the refusal text of OpenAI chat completions, streamed or not, in $ai_output_choices instead of an empty output. (2026-10-22)

8.16.0

Minor Changes

  • #5360 26e65ec Thanks @Radu-Raicea! - Add datasets, versioned scorers, and resumable offline evaluation uploads. (2026-10-22)

Patch Changes

  • #5121 0f5d25a Thanks @breken-ai! - Failed Vercel AI SDK generateText calls report the same $ai_provider as successful ones. (2026-10-22)

8.15.2

Patch Changes

8.15.1

Patch Changes

  • #5375 def5ab4 Thanks @shehjaddev! - fix: Capture Anthropic extended thinking blocks as reasoning content in captured output, streamed and not, and start time to first token at the first thinking delta. (2026-10-22)

8.15.0

Minor Changes

8.14.5

Patch Changes

  • #5357 b5e99d1 Thanks @shehjaddev! - fix: Capture Gemini thought summaries (thinkingConfig.includeThoughts) as reasoning content blocks instead of answer text, in responses, streamed output, replayed input and the ADK plugin. (2026-10-22)

8.14.4

Patch Changes

  • #5352 dd58d50 Thanks @pcbeingused333! - fix: Use the cumulative input and cache token counts from Anthropic's final message_delta when streaming with server tools. (2026-10-21)

8.14.3

Patch Changes

  • #5251 717d2fc Thanks @yoarajota! - Capture Chat Completions responses that contain custom tool calls instead of throwing from the wrapped create() call. (2026-10-20)

8.14.2

Patch Changes

  • #5155 a9d29f1 Thanks @gouveags! - Normalize AI tool-result capture and redact binary content while preserving existing provider limits. (2026-10-19)

8.14.1

Patch Changes

  • #5305 7319620 Thanks @carlos-marchal-ph! - Widen the supported @anthropic-ai/sdk peer range to >=0.112.3 <0.135.0, so installs can pick 0.134.0, the first version with OpenTelemetry tracing. (2026-10-15)

8.14.0

Minor Changes

8.13.7

Patch Changes

  • #5266 411d364 Thanks @jurajmajerik! - prompts.get() now makes one request when several callers ask for the same prompt at once, instead of one request per caller. Prompt fetches also time out after 10 seconds instead of hanging on a stalled connection, and PromptFetchError is exported so callers can tell a timeout or server error from a missing prompt. (2026-10-14)
  • Updated dependencies [e6598be]:

8.13.6

Patch Changes

8.13.5

Patch Changes

8.13.4

Patch Changes

8.13.3

Patch Changes

  • #5088 882606d Thanks @gouveags! - Preserve Gemini tool calls and results in captured generation input (2026-09-30)

8.13.2

Patch Changes

8.13.1

Patch Changes

8.13.0

Minor Changes

  • #5000 1dfde0e Thanks @jurajmajerik! - prompts.getAll() now works without a label. It fetches the latest version of every prompt in one request and warms the cache for plain prompts.get(name) calls. Previously the label was required by the method's type, and the server treats any label value as a filter, so there was no way to batch-fetch unlabeled prompts. (2026-09-17)

8.12.1

Patch Changes

  • #4961 8fb9367 Thanks @jurajmajerik! - Fix prompts.getAll returning an empty result instead of an error on PostHog servers that do not support fetching prompts by label. (2026-09-15)

8.12.0

Minor Changes

  • #4824 7ca1cdc Thanks @posthog! - Add a Claude Agent SDK integration that captures LLM analytics for @anthropic-ai/claude-agent-sdk queries (2026-09-15)

8.11.2

Patch Changes

8.11.1

Patch Changes

  • #4943 abf9123 Thanks @marandaneto! - Prevent tool argument serialization failures from disrupting Vercel tracing and LangChain callbacks. (2026-09-14)

8.11.0

Minor Changes

  • #4903 825d830 Thanks @jurajmajerik! - prompts.getAll({ label: 'production' }) fetches every prompt that carries a label in one request and stores them in the prompt cache, so later get(name, { label }) calls are cache hits. Apps with many prompts no longer need one request per prompt per cache cycle. Against a PostHog server that does not support labels on the prompt list endpoint yet, the call fails with a clear error instead of caching wrong versions. (2026-09-10)

8.10.4

Patch Changes

  • #4818 475743c Thanks @bernatixer! - fix(ai): only record a service tier the provider actually served. The requested service_tier no longer reaches $ai_model_parameters from any capture path — OpenAI error paths, the LangChain callback, and Anthropic events (whose 'auto'/'standard_only' request values were previously recorded) — so cost processing cannot price tokens at an unconfirmed tier. The LangChain callback now reads the served tier from the response (message response_metadata or generationInfo, depending on the adapter), and OpenAI and LangChain generations additionally emit the served tier as the explicit $ai_service_tier event property, which cost processing prices from. (2026-09-10)

8.10.3

Patch Changes

  • #4775 2fad74b Thanks @posthog! - Hold a stale prompt in the cache for a cooldown after a failed refetch, instead of going back to the network on every prompts.get() call. A rate-limited client now stays on cache until the limit clears. On a 429 the cooldown follows the server's Retry-After header. (2026-09-09)

8.10.2

Patch Changes

8.10.1

Patch Changes

  • #4736 c16a7ce Thanks @bernatixer! - Only terminal Responses API statuses become $ai_stop_reason (a queued or in-progress background run no longer records a lifecycle state as its stop reason), and the native OpenAI wrapper now names a truncated run by incomplete_details.reason (e.g. max_output_tokens) instead of the bare incomplete, matching the LangChain callback (2026-09-03)
  • Updated dependencies [dbbb58e]:

8.10.0

Minor Changes

  • #4687 657b173 Thanks @AhmadHammad21! - Add a Google ADK (@google/adk) observability adapter. @posthog/ai/adk exposes PostHogADKPlugin, an ADK BasePlugin that captures a full $ai_generation event (input, output, model, token usage, latency, finish reason, trace id, session id, distinct id and groups) for every model call an ADK agent makes, funnelling through the shared captureAiGeneration primitive so PostHog derives cost from the model and tokens. (2026-09-02)

8.9.3

Patch Changes

  • #4700 a105b77 Thanks @bernatixer! - Capture $ai_stop_reason from LangChain runs that use the OpenAI Responses API.

    The callback only understood Chat Completions vocabulary (finish_reason / stop_reason), so Responses API runs, which report status and incomplete_details.reason instead, never carried a stop reason. The Chat Completions keys keep priority, and incomplete_details.reason outranks status, so an early stop names its cause (for example max_output_tokens) instead of just incomplete. (2026-09-01)

  • Updated dependencies [e87820a]:

8.9.2

Patch Changes

  • #4664 86fe9da Thanks @bernatixer! - Interrupted or cancelled streams now report the token usage and latency they actually observed, instead of zeros, across the OpenAI, Anthropic, Gemini, Azure and Vercel wrappers. When usage was never reported, token counts and override costs are omitted entirely, so $ai_input_tokens can be absent where it was previously always 0. (2026-09-01)

8.9.1

Patch Changes

8.9.0

Minor Changes

Patch Changes

8.8.1

Patch Changes

8.8.0

Minor Changes

  • #4289 c9086de Thanks @carlos-marchal-ph! - Public beta captureAi() / captureAiImmediate(): AI events on a dedicated isolated endpoint with the event UUID returned. New enableFullAiCapture option replaces the internal _useAiLane / _enableMultimodalCapture; wrappers route through the AI endpoint and skip redaction/truncation when set (privacy mode still wins). (2026-08-13)

Patch Changes

8.7.1

Patch Changes

  • #4473 9b5922f Thanks @fivestarspicy! - fix(gemini): declare Gemini's cache accounting model on generations with cache reads, so ingestion prices cached tokens from $ai_cache_reporting_exclusive instead of inferring it from the token counts (2026-08-07)

8.7.0

Minor Changes

  • #4319 4d379bb Thanks @kdawgwilk! - Support AI SDK v7 provider peers for OpenTelemetry integrations and reject v7 models passed to the legacy withTracing wrapper. (2026-08-07)

8.6.8

Patch Changes

  • #4189 2831de1 Thanks @Fortiz2305! - Report cache-write tokens for the OpenAI wrapper. OpenAI-compatible providers that follow Anthropic's cache-write convention (e.g. Claude via OpenRouter) return cache-write tokens in the response usage (prompt_tokens_details.cache_write_tokens for Chat Completions, input_tokens_details.cache_write_tokens for Responses), but the wrapper only surfaced cache reads. It now populates $ai_cache_creation_input_tokens across Chat Completions and Responses (streaming, non-streaming, and parse()), so ingestion can price the cache-write premium for Claude/Anthropic models instead of under-reporting cost on cache-heavy calls. Completes the cache-aware cost fix started in #4071 (#3615). (2026-08-06)

  • #4236 d36a421 Thanks @gouveags! - Preserve Anthropic cache creation TTL breakdowns in streaming and LangChain generation events. (2026-08-06)

  • Updated dependencies [4751b33, 64ba193]:

8.6.7

Patch Changes

  • #4416 5a585b2 Thanks @carlos-marchal-ph! - Capture the reasoning text of assistant turns replayed in a Vercel AI SDK prompt. The input mapper read a non-existent reasoning field instead of the spec's text, so $ai_input reasoning parts arrived empty for multi-step agentic loops. (2026-08-05)

8.6.6

Patch Changes

  • #4365 63d87d8 Thanks @marandaneto! - Track OpenAI and Azure background Responses through their terminal state. (2026-08-04)

8.6.5

Patch Changes

8.6.4

Patch Changes

  • #4406 e2e88f6 Thanks @github-actions! - Capture Vercel AI SDK provider error status codes in $ai_http_status. (2026-08-04)

  • #4360 98bd34b Thanks @marandaneto! - Preserve provider SDK promise helpers when instrumenting requests, and accept the full Anthropic and Azure OpenAI client options, including custom fetch, timeout, and retry settings. (2026-08-04)

8.6.3

Patch Changes

  • #4361 0d79b00 Thanks @marandaneto! - Preserve stream cancellation and backpressure while monitoring AI responses. (2026-08-04)

  • #4362 cd4da1b Thanks @marandaneto! - Prevent telemetry failures from affecting provider calls and errors. (2026-08-04)

8.6.2

Patch Changes

8.6.1

Patch Changes

  • #4345 484c482 Thanks @willwearing! - Treat LangGraph control-flow exceptions (GraphInterrupt, NodeInterrupt, ParentCommand, and other is_bubble_up errors) as non-error trace and span completions in the LangChain callback, surfacing pending interrupts as $ai_output_state under the __interrupt__ key. (2026-08-03)

8.6.0

Minor Changes

  • #4335 9a453b9 Thanks @marco-g-pm! - The OpenAI Agents SDK groupId now also maps to $ai_session_id on $ai_trace and span events, so grouped runs show up as sessions in PostHog AI observability. $ai_group_id is still emitted alongside it. (2026-07-30)

Patch Changes

  • #4336 1eb04c1 Thanks @marco-g-pm! - Fix LangChain spans being named after their class instead of the runnable. LangChain passes runName as a bare string, which the name resolver skipped because it only inspected object arguments, so every tool span was captured as DynamicStructuredTool rather than the tool's own name. (2026-07-30)

8.5.0

Minor Changes

  • #4329 5baf90a Thanks @jurajmajerik! - Prompts.get() results now include config, the JSON object of model parameters or agent configuration stored with the prompt version in PostHog prompt management (null when the version has none). Config is carried through the client-side cache and the stale-cache fallback, and each result gets its own copy so mutating result.config cannot pollute later cache hits. The hardcoded fallback string has no config, so use defensive access like (result.config ?? {}).temperature. (2026-07-30)

8.4.3

Patch Changes

  • #4306 05088ff Thanks @marandaneto! - fix(ai): prefer the OpenAI service_tier reported by the response for accurate cost attribution (2026-07-29)

8.4.2

Patch Changes

  • #4072 0369b09 Thanks @nandinitiw! - fix(ai): capture OpenAI service_tier in $ai_model_parameters so PostHog can correctly attribute costs for flex and priority tier requests (2026-07-29)

8.4.1

Patch Changes

8.4.0

Minor Changes

  • #4163 45f5488 Thanks @jurajmajerik! - feat(ai): add a label option to Prompts.get() to fetch the prompt version a label (e.g. production) currently points to. Labeled fetches are cached separately, results carry the resolved label, and a warning is logged when the server does not resolve the requested label (older PostHog versions ignore the parameter and return the latest version). (2026-07-17)

8.3.1

Patch Changes

  • #4071 182434f Thanks @DerGeraetK! - fix(ai): declare $ai_cache_reporting_exclusive: false on OpenAI wrapper events so ingestion no longer double-bills cached input tokens for Claude models served through OpenAI-compatible hosts (e.g. OpenRouter). The flag stays unset when callers pass their own input or cache token counts through posthogProperties, so existing passthrough workarounds keep reporting correctly. (2026-07-16)

8.3.0

Minor Changes

  • #4084 f4b453a Thanks @marandaneto! - Add optional error callback support to the OpenAI Agents tracing processor. (2026-07-07)

8.2.3

Patch Changes

  • #4076 68640de Thanks @bamtheboozle! - fix: prevent unhandled promise rejection from crashing the host process when a streamed provider response errors mid-flight (OpenAI, Azure OpenAI, Anthropic wrappers) (2026-07-06)

8.2.2

Patch Changes

  • #3966 a277530 Thanks @marandaneto! - Skip capturing pending OpenAI background Responses without token usage. (2026-06-25)

8.2.1

Patch Changes

8.2.0

Minor Changes

  • #3793 b477c02 Thanks @richardsolomou! - feat: warn when a base_url points at the PostHog AI Gateway. The gateway emits its own $ai_generation, so routing through it double-captures (and, for billable products, double-bills) every call. Detection covers the provider wrappers (OpenAI, Azure, Anthropic, Gemini, Vercel), LangChain, OpenAI Agents, direct captureAiGeneration callers, and the OTel exporter/processor (via the span's server.address / url.full). The warning logs on every routed call; the event is left untouched, since it carries data the gateway never sees (groups, custom properties, trace hierarchy). (2026-06-11)

8.1.11

Patch Changes

8.1.10

Patch Changes

8.1.9

Patch Changes

8.1.8

Patch Changes

8.1.7

Patch Changes

8.1.6

Patch Changes

8.1.5

Patch Changes

8.1.4

Patch Changes

8.1.3

Patch Changes

8.1.2

Patch Changes

8.1.1

Patch Changes

8.1.0

Minor Changes

  • #3751 9140a67 Thanks @richardsolomou! - feat: populate $ai_base_url on the Vercel and OpenAI Agents instrumentation paths so gateway-routed $ai_generation events can be deduped on ingestion. The Vercel middleware recovers the base URL from the provider's internal config (config.baseURL, or the config.url({ path }) closure used by @ai-sdk/openai / openai-compatible) instead of hardcoding an empty string. The OpenAI Agents processor emits it from model_config.base_url when the SDK exposes it (best-effort; the SDK omits it for Responses calls and for chat calls with model settings). (2026-06-09)

8.0.1

Patch Changes

8.0.0

Major Changes

  • #3771 227c9b0 Thanks @dustinbyrne! - Major release: move provider SDKs to optional peer dependencies and clean up staged deprecations.

    Optional peer dependencies (#3610): openai, @anthropic-ai/sdk, @google/genai, and @langchain/core are now optional peer dependencies, and the unused langchain dependency is dropped — you only install the SDK for the integration you use. Integration clients are no longer exported from the package root; import them from their subpaths:

     1- import { OpenAI } from '@posthog/ai'
     2+ import { OpenAI } from '@posthog/ai/openai'        // npm install openai
     3- import { AzureOpenAI } from '@posthog/ai'
     4+ import { AzureOpenAI } from '@posthog/ai/openai'   // npm install openai
     5- import { Anthropic } from '@posthog/ai'
     6+ import { Anthropic } from '@posthog/ai/anthropic'  // npm install @anthropic-ai/sdk
     7- import { GoogleGenAI } from '@posthog/ai'
     8+ import { GoogleGenAI } from '@posthog/ai/gemini'   // npm install @google/genai
     9- import { LangChainCallbackHandler } from '@posthog/ai'
    10+ import { LangChainCallbackHandler } from '@posthog/ai/langchain'  // npm install @langchain/core
    

    withTracing (Vercel AI SDK) and captureAiGeneration remain exported from the package root and need no provider SDK.

    Removed deprecations:

    • Prompts.get() now always returns a PromptResult object ({ source, prompt, name, version }) — the plain-string return and the withMetadata option are gone. Read the template from result.prompt:

       1- const template = await prompts.get('my-prompt')
       2- const compiled = prompts.compile(template, vars)
       3+ const result = await prompts.get('my-prompt')
       4+ const compiled = prompts.compile(result.prompt, vars)
      
    • PostHogTraceExporter and PostHogSpanProcessor no longer accept the deprecated apiKey option — use projectToken:

       1- new PostHogTraceExporter({ apiKey: 'phc_...' })
       2+ new PostHogTraceExporter({ projectToken: 'phc_...' })
       3- new PostHogSpanProcessor({ apiKey: 'phc_...' })
       4+ new PostHogSpanProcessor({ projectToken: 'phc_...' })
       5``` (2026-06-08)
      

Patch Changes

7.21.0

Minor Changes

  • #3762 a6234bd Thanks @carlos-marchal-ph! - Redact base64/binary multimodal content from AI spans in the OTel PostHogSpanProcessor and PostHogTraceExporter before export, matching the redaction already applied by the direct provider wrappers. Content is redacted by value (data URLs and large base64 blobs) across span attributes and span events, so it works regardless of which GenAI semantic convention produced the span. (2026-06-08)

7.20.14

Patch Changes

7.20.13

Patch Changes

  • #3624 be7c3c7 Thanks @pntech20! - Preserve OpenAI APIPromise response helpers on instrumented OpenAI wrapper calls. (2026-06-05)

7.20.12

Patch Changes

7.20.11

Patch Changes

7.20.10

Patch Changes

7.20.9

Patch Changes

7.20.8

Patch Changes

7.20.7

Patch Changes

7.20.6

Patch Changes

7.20.5

Patch Changes

7.20.4

Patch Changes

7.20.3

Patch Changes

7.20.2

Patch Changes

7.20.1

Patch Changes

7.20.0

Minor Changes

  • #3306 1a2f8a8 Thanks @johnsykim! - Add $ai_completion_id and $ai_provider_metadata to $ai_generation events for the OpenAI and Azure OpenAI wrappers. $ai_completion_id is the provider's response ID (e.g. chatcmpl-… / resp_…); $ai_provider_metadata carries OpenAI-specific fields (system_fingerprint, request_id). Together they enable correlating PostHog events with OpenAI's Logs dashboard (platform.openai.com/logs/{completion_id}). The same options (completionId, providerMetadata) are now accepted by the public captureAiGeneration primitive so other provider wrappers can follow the same pattern. (2026-05-29)

7.19.7

Patch Changes

7.19.6

Patch Changes

  • #3668 7c80b2e Thanks @rafaeelaudibert! - Expose projectToken in addition to apiKey for PostHogTraceExporter

    We're moving towards a place where we're calling this projectToken everywhere. Let's release this as a patch version because it's a tiny change and we still support the old usage. This might be dropped in the next packages/ai major version. (2026-05-28)

7.19.5

Patch Changes

7.19.4

Patch Changes

7.19.3

Patch Changes

7.19.2

Patch Changes

7.19.1

Patch Changes

7.19.0

Minor Changes

7.18.12

Patch Changes

7.18.11

Patch Changes

7.18.10

Patch Changes

7.18.9

Patch Changes

7.18.8

Patch Changes

7.18.7

Patch Changes

7.18.6

Patch Changes

7.18.5

Patch Changes

7.18.4

Patch Changes

7.18.3

Patch Changes

7.18.2

Patch Changes

7.18.1

Patch Changes

7.18.0

Minor Changes

7.17.5

Patch Changes

7.17.4

Patch Changes

7.17.3

Patch Changes

7.17.2

Patch Changes

7.17.1

Patch Changes

  • #3507 38e85c9 Thanks @richardsolomou! - perf(vercel): drop O(N²) prompt trim and reuse TextEncoder/TextDecoder in mapVercelPrompt/truncate so long conversations no longer block the main thread for hundreds of milliseconds in withTracing's stream flush (2026-04-30)

7.17.0

Minor Changes

  • #3499 0601162 Thanks @richardsolomou! - Add captureAiGeneration, a generic primitive for emitting $ai_generation events from LLM calls that don't go through one of the wrapped clients (Cloudflare Workers AI, TanStack AI, custom HTTP, etc.). All built-in wrappers (withTracing, OpenAI, Anthropic, GoogleGenAI) now funnel through the same primitive, so external events are indistinguishable from SDK-wrapped ones. (2026-04-30)

7.16.15

Patch Changes

7.16.14

Patch Changes

7.16.13

Patch Changes

7.16.12

Patch Changes

  • #3487 09b4b3d Thanks @richardsolomou! - Widen the @opentelemetry/exporter-trace-otlp-http peer dependency range from ^0.200.0 (which only matched 0.200.x) to >=0.200.0 <1.0.0, so newer 0.x releases brought in by other OpenTelemetry-aware packages no longer trigger ERESOLVE failures or require --legacy-peer-deps. (2026-04-27)

7.16.11

Patch Changes

7.16.10

Patch Changes

7.16.9

Patch Changes

7.16.8

Patch Changes

7.16.7

Patch Changes

7.16.6

Patch Changes

7.16.5

Patch Changes

7.16.4

Patch Changes

7.16.3

Patch Changes

7.16.2

Patch Changes

7.16.1

Patch Changes

7.16.0

Minor Changes

  • #3387 7ea6e26 Thanks @carlos-marchal-ph! - Prompts.get() now accepts { withMetadata: true } and returns a PromptResult object containing source (api, cache, stale_cache, or code_fallback), name, and version alongside the prompt text. The previous plain-string return is deprecated and will be removed in a future major version. (2026-04-15)

7.15.0

Minor Changes

  • #3358 85d3bd1 Thanks @richardsolomou! - Add PostHogSpanProcessor as a self-contained OpenTelemetry SpanProcessor that handles batching and export internally. Both PostHogSpanProcessor and PostHogTraceExporter now automatically filter to AI-related spans only (gen_ai.*, llm.*, ai.*, traceloop.*). (2026-04-14)

  • #3377 b90b54e Thanks @andrewm4894! - Add OpenAI Agents SDK tracing support via @posthog/ai/openai-agents. Implements PostHogTracingProcessor that captures agent traces, spans, and LLM generations as PostHog LLM analytics events. Supports all span types including generation, response, function/tool, agent, handoff, guardrail, custom, audio, and MCP. (2026-04-14)

7.14.0

Minor Changes

7.13.2

Patch Changes

7.13.1

Patch Changes

7.13.0

Minor Changes

Patch Changes

7.12.8

Patch Changes

7.12.7

Patch Changes

7.12.6

Patch Changes

  • #3299 4561c25 Thanks @richardsolomou! - Remove PostHogTraceExporter from the main entry point to avoid crashing when @opentelemetry/exporter-trace-otlp-http is not installed. Use @posthog/ai/otel to import it instead. (2026-03-31)

7.12.5

Patch Changes

7.12.4

Patch Changes

7.12.3

Patch Changes

7.12.2

Patch Changes

7.12.1

Patch Changes

7.12.0

Minor Changes

  • #3232 476a823 Thanks @richardsolomou! - Replace otel client-side span mapping with PostHogTraceExporter. PostHog now converts gen_ai.* spans into $ai_generation events server-side, so the client-side mapper pipeline (PostHogSpanProcessor, captureSpan, aiSdkSpanMapper) has been replaced with a simple OTLPTraceExporter wrapper. (2026-03-18)

Patch Changes

7.11.2

Patch Changes

7.11.1

Patch Changes

7.11.0

Minor Changes

  • #3210 2d9eb60 Thanks @Radu-Raicea! - Add version-specific Prompts.clearCache(name, version) support and switch prompt caching to structured name/version entries instead of string-encoded cache keys. (2026-03-09)

7.10.0

Minor Changes

  • #3206 43a81c5 Thanks @Radu-Raicea! - Add version-aware prompt fetching to the Prompts SDK so callers can request a specific published prompt version without colliding with the latest prompt cache entry. (2026-03-09)

7.9.5

Patch Changes

  • #3194 eccec25 Thanks @Radu-Raicea! - Sanitize inline base64 video_url's in chat completions calls, which is supported by OpenRouter for video understanding models (2026-03-03)

7.9.4

Patch Changes

7.9.3

Patch Changes

7.9.2

Patch Changes

7.9.1

Patch Changes

7.9.0

Minor Changes

7.8.13

Patch Changes

7.8.12

Patch Changes

7.8.11

Patch Changes

7.8.10

Patch Changes

7.8.9

Patch Changes

7.8.8

Patch Changes

7.8.7

Patch Changes

7.8.6

Patch Changes

7.8.5

Patch Changes

7.8.4

Patch Changes

7.8.3

Patch Changes

7.8.2

Patch Changes

7.8.1

Patch Changes

7.8.0

Minor Changes

7.7.0

Minor Changes

7.6.1

Patch Changes

7.6.0

Minor Changes

  • #2955 6db4b48 Thanks @richardsolomou! - Add rawUsage field to capture raw provider usage metadata for backend cost calculations (2026-01-27)

Patch Changes

7.5.4

Patch Changes

7.5.3

Patch Changes

7.5.2

Patch Changes

7.5.1

Patch Changes

7.5.0

Minor Changes

Patch Changes

7.4.3

Patch Changes

7.4.2

Patch Changes

  • #2852 308daf0 Thanks @andrewm4894! - fix(vercel): preserve prototype getter properties when wrapping models (2026-01-12)

7.4.1

Patch Changes

7.4.0

Minor Changes

  • #2593 fba9fb2 Thanks @daibhin! - track LLMA trace_id on exceptions and exception_id on traces (2026-01-08)

Patch Changes

7.3.2

Patch Changes

7.3.1

Patch Changes

  • #2850 b5dbf56 Thanks @andrewm4894! - fix(gemini): expose all GoogleGenAI constructor parameters in wrapper

    The MonitoringGeminiConfig interface now extends GoogleGenAIOptions from @google/genai, allowing users to pass all available constructor parameters like googleAuthOptions and httpOptions without TypeScript errors. (2026-01-06)

7.3.0

Minor Changes

  • #2711 8c3a21e Thanks @andrewm4894! - Add support for both Vercel AI SDK 5 and 6

    Changes:

    • Runtime version detection via model.specificationVersion
    • Support both LanguageModelV2 (SDK 5) and LanguageModelV3 (SDK 6)
    • @ai-sdk/provider is now an optional peer dependency (supports both v2 and v3)
    • Removed unused ai peer dependency (only type imports from @ai-sdk/provider are used)
    • No breaking changes - existing SDK 5 users can continue without modification (2025-12-22)

Patch Changes

  • #2789 6b415a0 Thanks @andrewm4894! - fix: extract model from response for OpenAI stored prompts

    When using OpenAI stored prompts, the model is defined in the OpenAI dashboard rather than passed in the API request. This change adds a fallback to extract the model from the response object when not provided in kwargs. (2025-12-22)

  • Updated dependencies [04065b9]:

7.2.2

Patch Changes

7.2.1

Patch Changes

7.2.0

Minor Changes

Patch Changes

7.1.2

Patch Changes

7.1.1

Patch Changes

7.1.0

Minor Changes

  • #2498 aa9f637 Thanks @Tehnix! - Added support for OpenAI audio transcriptions API. You can now track and monitor OpenAI Whisper transcription requests through the @posthog/ai SDK, with support for both streaming and non-streaming transcriptions, verbose JSON responses, and all standard transcription parameters (language, response_format, timestamp_granularities).

7.0.0

Major Changes

  • #2554 8e8d2f5 Thanks @carlos-marchal-ph! - Update LLM provider SDKs to latest versions
    • openai: 5.20.1 → 6.8.1
    • @anthropic-ai/sdk: 0.63.1 → 0.67.0
    • @google/genai: 1.19.0 → 1.29.0
    • langchain: 0.3.33 → 1.0.0
    • @langchain/core: 0.3.75 → 1.0.0
    • ai: 5.0.42 → 5.0.87
    • zod: 4.1.5 → 4.1.8

6.6.0

Minor Changes

6.5.1

Patch Changes

6.5.0

Minor Changes

  • #2496 7253bb3 Thanks @andrewm4894! - feat: add $ai_framework property for framework integrations

    Adds a simple $ai_framework property to AI events when using framework layers (LangChain, Vercel AI SDK). Direct provider calls (OpenAI, Anthropic, Gemini) do not include this property, eliminating redundant data where framework would duplicate the provider name.

    Example with framework:

     1{
     2  "$ai_framework": "langchain",
     3  "$ai_provider": "openai",
     4  "$ai_model": "gpt-4"
     5}
    

    Example without framework:

     1{
     2  "$ai_provider": "openai",
     3  "$ai_model": "gpt-4"
     4}
    

6.4.4

Patch Changes

  • #2468 873538b Thanks @andrewm4894! - fix: prevent [object Object] in content serialization - structured content is now properly JSON-stringified instead of being converted to "[object Object]"

6.4.3

Patch Changes

6.4.2

Patch Changes

6.4.1

Patch Changes

6.4.0

Minor Changes

6.3.3

Patch Changes

6.3.2

Patch Changes

6.3.1

Patch Changes

6.3.0

Minor Changes

6.2.0

Minor Changes

6.1.2

Patch Changes

6.1.1

Patch Changes

6.1.0

Minor Changes

  • #2216 57752f4 Thanks @k11kirky! - Add support for reasoning and cache tokens in gemini + fix token calc in vercel

6.0.1

Patch Changes

6.0.0

Major Changes

Patch Changes

5.2.3

Patch Changes

5.2.2

  • Add support for parsing tool calls from reasoning models in LangChain by converting the tool call format to the expected shape

5.2.1

  • Fix crash when importing @posthog/ai with OpenAI SDK v5.x by deferring access to Chat, Completions, and Responses classes until runtime

5.2.0

  • Fix anonymous events

5.1.0

  • Add responses + parse

5.0.1

  • Bump posthog-node to v5.0.0

5.0.0

  • Major bump for breaking change:
  • Require node engine >20
  • support for @google/genai

4.4.0

  • Make posthog-node a peer dependency to avoid bundling implementation code

4.3.2

  • Fix exported file extensions to work with older Node versions

4.3.1

  • Remove fullDebug mode
  • Add posthogCaptureImmediate to await a promise for each capture (for serverless environments)
  • Fix openai test

4.2.1

  • Add fullDebug mode and limit full size of event input

4.1.0

  • add truncation to vercel ai sdk inputs and outputs

4.0.1

  • add new util to sanitize inputs, outputs and errors

4.0.0

  • feat: separate out packages as separate exports so you can import { OpenAI } from @posthog/ai/openai and reduce import size

3.3.2 - 2025-03-25

  • fix: langchain name mapping

3.3.1 - 2025-03-13

  • fix: fix vercel output mapping and token caching

3.3.0 - 2025-03-08

  • feat: add reasoning and cache tokens to openai and anthropic
  • feat: add tool support for vercel
  • feat: add support for other media types vercel

3.2.1 - 2025-02-11

  • fix: add experimental_wrapLanguageModel to vercel middleware supporting older versions of ai

3.2.0 - 2025-02-11

  • feat: change how we handle streaming support for openai and anthropic

3.1.1 - 2025-02-07

  • fix: bump ai to 4.1.0

3.1.0 - 2025-02-07

  • feat: add posthogCostOverride, posthogModelOverride, and posthogProviderOverride to sendEventToPosthog for vercel

2.4.0 - 2025-02-03

  • feat: add anthropic support for sdk