Packages

@posthog/ai

8.22.0 · 20 Nov 2026MIT1.9M / weekRepositoryHomepagenpmAtom feed

Your version

270 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  1. 8.x · latest line
  2. 8.10.0

    2 Sep 2026
    • 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)

  3. 8.9.3

    1 Sep 2026
    • 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)

  4. 8.9.2

    1 Sep 2026
    • 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)

  5. 8.9.1

    1 Sep 2026
    • Preserve Anthropic workspace IDs on wrapped provider promises and support @anthropic-ai/sdk versions from 0.112.3 through 0.120.x.
      (2026-09-01)

  6. 8.9.0

    27 Aug 2026
    • Add LangChain v1 agent middleware for AI observability.
      (2026-08-27)

  7. 8.8.1

    25 Aug 2026
    • Share OpenAI-compatible telemetry reducers across OpenAI and Azure and align Azure usage, tools, stop reason, web search, background output, and sanitization telemetry.
      (2026-08-25)

  8. 8.8.0

    13 Aug 2026
    • 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)

  9. 8.7.1

    7 Aug 2026
    • 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)

  10. 8.7.0

    7 Aug 2026
    • Support AI SDK v7 provider peers for OpenTelemetry integrations and reject v7 models passed to the legacy withTracing wrapper.
      (2026-08-07)

  11. 8.6.8

    6 Aug 2026
    • 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)

    • Preserve Anthropic cache creation TTL breakdowns in streaming and LangChain generation events.
      (2026-08-06)

  12. 8.6.7

    5 Aug 2026
    • 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)

  13. 8.6.6

    4 Aug 2026
    • Track OpenAI and Azure background Responses through their terminal state.
      (2026-08-04)

  14. 8.6.5

    4 Aug 2026
    • Capture failed and incomplete Responses API results correctly.
      (2026-08-04)

    • Redact binary content consistently across AI integrations.
      (2026-08-04)

  15. 8.6.4

    4 Aug 2026
    • Capture Vercel AI SDK provider error status codes in $ai_http_status.
      (2026-08-04)

    • 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)

  16. 8.6.3

    4 Aug 2026
    • Preserve stream cancellation and backpressure while monitoring AI responses.
      (2026-08-04)

    • Prevent telemetry failures from affecting provider calls and errors.
      (2026-08-04)

  17. 8.6.2

    4 Aug 2026
    • Capture Chat Completions usage from OpenAI Agents spans.
      (2026-08-04)

    • Remove the undeclared OpenTelemetry core runtime dependency.
      (2026-08-04)

    • Resolve OpenAI Agents APIs through the declared peer dependency.
      (2026-08-04)

  18. 8.6.1

    3 Aug 2026
    • 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)

  19. 8.6.0

    30 Jul 2026
    • 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)

    • 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)

  20. 8.5.0

    30 Jul 2026
    • 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)

  21. 8.4.3

    29 Jul 2026
    • ai: Prefer the OpenAI service_tier reported by the response for accurate cost attribution
      (2026-07-29)

  22. 8.4.2

    29 Jul 2026
    • ai: Capture OpenAI service_tier in $ai_model_parameters so PostHog can correctly attribute costs for flex and priority tier requests
      (2026-07-29)

  23. 8.4.1

    28 Jul 2026
    • Redact base64 content from LangChain trace and span input and output state.
      (2026-07-28)

  24. 8.4.0

    17 Jul 2026
    • 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)

  25. 8.3.1

    16 Jul 2026
    • 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)

  26. 8.3.0

    7 Jul 2026
    • Add optional error callback support to the OpenAI Agents tracing processor.
      (2026-07-07)

  27. 8.2.3

    6 Jul 2026
    • 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)

  28. 8.2.2

    25 Jun 2026
    • Skip capturing pending OpenAI background Responses without token usage.
      (2026-06-25)

  29. 8.2.1

    16 Jun 2026
    • Wrap the Azure OpenAI responses API in PostHogAzureOpenAI so responses.create calls are tracked, matching the non-Azure PostHogOpenAI client.
      (2026-06-16)

  30. 8.2.0

    11 Jun 2026
    • 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)

  31. 8.1.2 – 8.1.1110 releases that only update dependencies@posthog/core 1.32.3posthog-node 5.36.17Show each
  32. 8.1.1

    9 Jun 2026
    • Reduce duplicate internal code found by dry4ts.
      (2026-06-09)

  33. 8.1.0

    9 Jun 2026
    • 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)

  34. 8.0.1

    8 Jun 2026
  35. 8.0.0

    8 Jun 2026
    • Breaking

      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:

      - import { OpenAI } from '@posthog/ai'
      + import { OpenAI } from '@posthog/ai/openai'        // npm install openai
      - import { AzureOpenAI } from '@posthog/ai'
      + import { AzureOpenAI } from '@posthog/ai/openai'   // npm install openai
      - import { Anthropic } from '@posthog/ai'
      + import { Anthropic } from '@posthog/ai/anthropic'  // npm install @anthropic-ai/sdk
      - import { GoogleGenAI } from '@posthog/ai'
      + import { GoogleGenAI } from '@posthog/ai/gemini'   // npm install @google/genai
      - import { LangChainCallbackHandler } from '@posthog/ai'
      + 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:

  36. 7.x
  37. 7.21.0

    8 Jun 2026
    • 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)

  38. 7.20.14

    6 Jun 2026
  39. 7.20.13

    5 Jun 2026
    • Preserve OpenAI APIPromise response helpers on instrumented OpenAI wrapper calls.
      (2026-06-05)

  40. 7.20.9 – 7.20.124 releases that only update dependencies@posthog/core 1.30.9posthog-node 5.36.3Show each

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.