@posthog/ai
8.22.0 · 20 Nov 2026MIT1.9M / weekRepositoryHomepagenpmAtom feed
8.22.0 is the newest release of 8.x.
In short
1 breaking2 internal
- Breaking
Major release: move provider SDKs to optional peer dependencies and clean up staged deprecations.
Release note
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)
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.