@posthog/ai
8.22.0 · 20 Nov 2026MIT1.9M / weekRepositoryHomepagenpmAtom feed
270 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 8.x · latest line
8.10.0
2 Sep 2026Add a Google ADK (
@google/adk) observability adapter.@posthog/ai/adkexposesPostHogADKPlugin, an ADKBasePluginthat captures a full$ai_generationevent (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 sharedcaptureAiGenerationprimitive so PostHog derives cost from the model and tokens.
(2026-09-02)
8.9.3
1 Sep 2026Capture
$ai_stop_reasonfrom LangChain runs that use the OpenAI Responses API.The callback only understood Chat Completions vocabulary (
finish_reason/stop_reason), so Responses API runs, which reportstatusandincomplete_details.reasoninstead, never carried a stop reason. The Chat Completions keys keep priority, andincomplete_details.reasonoutranksstatus, so an early stop names its cause (for examplemax_output_tokens) instead of justincomplete. (2026-09-01)
Patch Changes
Capture
$ai_stop_reasonfrom LangChain runs that use the OpenAI Responses API.The callback only understood Chat Completions vocabulary (
finish_reason/stop_reason), so Responses API runs, which reportstatusandincomplete_details.reasoninstead, never carried a stop reason. The Chat Completions keys keep priority, andincomplete_details.reasonoutranksstatus, so an early stop names its cause (for examplemax_output_tokens) instead of justincomplete. (2026-09-01)
8.9.2
1 Sep 2026Interrupted 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_tokenscan be absent where it was previously always0.
(2026-09-01)
8.9.1
1 Sep 2026Preserve Anthropic workspace IDs on wrapped provider promises and support
@anthropic-ai/sdkversions from 0.112.3 through 0.120.x.
(2026-09-01)
Patch Changes
Preserve Anthropic workspace IDs on wrapped provider promises and support
@anthropic-ai/sdkversions from 0.112.3 through 0.120.x.
(2026-09-01)
8.9.0
27 Aug 2026Add LangChain v1 agent middleware for AI observability.
(2026-08-27)
Minor Changes
Add LangChain v1 agent middleware for AI observability.
(2026-08-27)
8.8.1
25 Aug 2026Share 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)
Patch Changes
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.0
13 Aug 2026Public beta
captureAi()/captureAiImmediate(): AI events on a dedicated isolated endpoint with the event UUID returned. NewenableFullAiCaptureoption replaces the internal_useAiLane/_enableMultimodalCapture; wrappers route through the AI endpoint and skip redaction/truncation when set (privacy mode still wins).
(2026-08-13)
Minor Changes
Public beta
captureAi()/captureAiImmediate(): AI events on a dedicated isolated endpoint with the event UUID returned. NewenableFullAiCaptureoption replaces the internal_useAiLane/_enableMultimodalCapture; wrappers route through the AI endpoint and skip redaction/truncation when set (privacy mode still wins).
(2026-08-13)
8.7.1
7 Aug 2026gemini: Declare Gemini's cache accounting model on generations with cache reads, so ingestion prices cached tokens from
$ai_cache_reporting_exclusiveinstead of inferring it from the token counts
(2026-08-07)
8.7.0
7 Aug 2026Support AI SDK v7 provider peers for OpenTelemetry integrations and reject v7 models passed to the legacy
withTracingwrapper.
(2026-08-07)
8.6.8
6 Aug 2026Report 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_tokensfor Chat Completions,input_tokens_details.cache_write_tokensfor Responses), but the wrapper only surfaced cache reads. It now populates$ai_cache_creation_input_tokensacross Chat Completions and Responses (streaming, non-streaming, andparse()), 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)
Patch Changes
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_tokensfor Chat Completions,input_tokens_details.cache_write_tokensfor Responses), but the wrapper only surfaced cache reads. It now populates$ai_cache_creation_input_tokensacross Chat Completions and Responses (streaming, non-streaming, andparse()), 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)
8.6.7
5 Aug 2026Capture the reasoning text of assistant turns replayed in a Vercel AI SDK prompt. The input mapper read a non-existent
reasoningfield instead of the spec'stext, so$ai_inputreasoning parts arrived empty for multi-step agentic loops.
(2026-08-05)
8.6.6
4 Aug 2026Track OpenAI and Azure background Responses through their terminal state.
(2026-08-04)
8.6.5
4 Aug 2026Capture failed and incomplete Responses API results correctly.
(2026-08-04)Redact binary content consistently across AI integrations.
(2026-08-04)
Patch Changes
Capture failed and incomplete Responses API results correctly.
(2026-08-04)Redact binary content consistently across AI integrations.
(2026-08-04)
8.6.4
4 Aug 2026Capture 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)
8.6.3
4 Aug 2026Preserve stream cancellation and backpressure while monitoring AI responses.
(2026-08-04)Prevent telemetry failures from affecting provider calls and errors.
(2026-08-04)
8.6.2
4 Aug 2026Capture 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)
Patch Changes
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)Support current LangChain message usage and response metadata.
(2026-08-04)Safely capture circular and otherwise unknown telemetry values with a shared JSON-safe value converter.
(2026-08-04)Handle Vercel AI stream errors and cancellation exactly once.
(2026-08-04)
8.6.1
3 Aug 2026Treat LangGraph control-flow exceptions (
GraphInterrupt,NodeInterrupt,ParentCommand, and otheris_bubble_uperrors) as non-error trace and span completions in the LangChain callback, surfacing pending interrupts as$ai_output_stateunder the__interrupt__key.
(2026-08-03)
8.6.0
30 Jul 2026The OpenAI Agents SDK
groupIdnow also maps to$ai_session_idon$ai_traceand span events, so grouped runs show up as sessions in PostHog AI observability.$ai_group_idis still emitted alongside it.
(2026-07-30)Fix LangChain spans being named after their class instead of the runnable. LangChain passes
runNameas a bare string, which the name resolver skipped because it only inspected object arguments, so every tool span was captured asDynamicStructuredToolrather than the tool's own name.
(2026-07-30)
8.5.0
30 Jul 2026Prompts.get()results now includeconfig, the JSON object of model parameters or agent configuration stored with the prompt version in PostHog prompt management (nullwhen 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 mutatingresult.configcannot pollute later cache hits. The hardcodedfallbackstring has no config, so use defensive access like(result.config ?? {}).temperature.
(2026-07-30)
8.4.3
29 Jul 2026ai: Prefer the OpenAI
service_tierreported by the response for accurate cost attribution
(2026-07-29)
8.4.2
29 Jul 2026ai: Capture OpenAI
service_tierin$ai_model_parametersso PostHog can correctly attribute costs for flex and priority tier requests
(2026-07-29)
8.4.1
28 Jul 2026Redact base64 content from LangChain trace and span input and output state.
(2026-07-28)
8.4.0
17 Jul 2026ai: Add a
labeloption toPrompts.get()to fetch the prompt version a label (e.g.production) currently points to. Labeled fetches are cached separately, results carry the resolvedlabel, 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
16 Jul 2026ai: Declare
$ai_cache_reporting_exclusive: falseon 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 throughposthogProperties, so existing passthrough workarounds keep reporting correctly.
(2026-07-16)
8.3.0
7 Jul 2026Add optional error callback support to the OpenAI Agents tracing processor.
(2026-07-07)
8.2.3
6 Jul 2026Prevent 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
25 Jun 2026Skip capturing pending OpenAI background Responses without token usage.
(2026-06-25)
8.2.1
16 Jun 2026Wrap the Azure OpenAI
responsesAPI inPostHogAzureOpenAIsoresponses.createcalls are tracked, matching the non-AzurePostHogOpenAIclient.
(2026-06-16)
Patch Changes
Wrap the Azure OpenAI
responsesAPI inPostHogAzureOpenAIsoresponses.createcalls are tracked, matching the non-AzurePostHogOpenAIclient.
(2026-06-16)
8.2.0
11 Jun 2026Warn when a
base_urlpoints 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, directcaptureAiGenerationcallers, and the OTel exporter/processor (via the span'sserver.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.2 – 8.1.1110 releases that only update dependencies@posthog/core 1.32.3posthog-node 5.36.17Show each
- 8.1.1111 Jun 2026@posthog/core 1.32.3posthog-node 5.36.17
- 8.1.1011 Jun 2026@posthog/core 1.32.2posthog-node 5.36.16
- 8.1.910 Jun 2026@posthog/core 1.32.1posthog-node 5.36.15
- 8.1.810 Jun 2026@posthog/core 1.32.0posthog-node 5.36.14
- 8.1.710 Jun 2026@posthog/core 1.31.4posthog-node 5.36.13
- 8.1.610 Jun 2026@posthog/core 1.31.3posthog-node 5.36.12
- 8.1.510 Jun 2026@posthog/core 1.31.2posthog-node 5.36.11
- 8.1.410 Jun 2026@posthog/core 1.31.1posthog-node 5.36.10
- 8.1.310 Jun 2026@posthog/core 1.31.0posthog-node 5.36.9
- 8.1.29 Jun 2026@posthog/core 1.30.14posthog-node 5.36.8
8.1.1
9 Jun 2026Reduce duplicate internal code found by dry4ts.
(2026-06-09)
Patch Changes
Reduce duplicate internal code found by dry4ts.
(2026-06-09)
8.1.0
9 Jun 2026Populate
$ai_base_urlon the Vercel and OpenAI Agents instrumentation paths so gateway-routed$ai_generationevents can be deduped on ingestion. The Vercel middleware recovers the base URL from the provider's internalconfig(config.baseURL, or theconfig.url({ path })closure used by@ai-sdk/openai/openai-compatible) instead of hardcoding an empty string. The OpenAI Agents processor emits it frommodel_config.base_urlwhen 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
8 Jun 2026Only updates dependencies:@posthog/core 1.30.12posthog-node 5.36.6
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/coreare now optional peer dependencies, and the unusedlangchaindependency 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/corewithTracing(Vercel AI SDK) andcaptureAiGenerationremain exported from the package root and need no provider SDK.Removed deprecations:
Major Changes
- 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/coreare now optional peer dependencies, and the unusedlangchaindependency 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/corewithTracing(Vercel AI SDK) andcaptureAiGenerationremain exported from the package root and need no provider SDK.Removed deprecations:
Prompts.get()now always returns aPromptResultobject ({ source, prompt, name, version }) — the plain-string return and thewithMetadataoption are gone. Read the template fromresult.prompt:- const template = await prompts.get('my-prompt') - const compiled = prompts.compile(template, vars) + const result = await prompts.get('my-prompt') + const compiled = prompts.compile(result.prompt, vars)PostHogTraceExporterandPostHogSpanProcessorno longer accept the deprecatedapiKeyoption — useprojectToken:- new PostHogTraceExporter({ apiKey: 'phc_...' }) + new PostHogTraceExporter({ projectToken: 'phc_...' }) - new PostHogSpanProcessor({ apiKey: 'phc_...' }) + new PostHogSpanProcessor({ projectToken: 'phc_...' }) ``` (2026-06-08)
- 7.x
7.21.0
8 Jun 2026Redact base64/binary multimodal content from AI spans in the OTel
PostHogSpanProcessorandPostHogTraceExporterbefore 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
6 Jun 2026Only updates dependencies:@posthog/core 1.30.10posthog-node 5.36.4
7.20.13
5 Jun 2026Preserve OpenAI APIPromise response helpers on instrumented OpenAI wrapper calls.
(2026-06-05)
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.