@posthog/ai 8.6.8 → 8.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -406,7 +406,7 @@ function sanitizeValues(obj) {
406
406
  return jsonSafe;
407
407
  }
408
408
 
409
- var version = "8.6.8";
409
+ var version = "8.7.0";
410
410
 
411
411
  const DEFAULT_MAX_DEPTH = 3;
412
412
  const MAX_STACK_LINES = 20;
@@ -655,6 +655,12 @@ const captureAiGeneration = async (client, options) => {
655
655
  function isV3Model(model) {
656
656
  return model.specificationVersion === 'v3';
657
657
  }
658
+ function getSpecificationVersion(model) {
659
+ if (typeof model === 'object' && model !== null && 'specificationVersion' in model) {
660
+ return model.specificationVersion;
661
+ }
662
+ return undefined;
663
+ }
658
664
 
659
665
  // Content types for the output array
660
666
 
@@ -997,6 +1003,10 @@ const adjustAnthropicV3CacheTokens = (model, modelId, provider, usage) => {
997
1003
  * Automatically detects the model version and applies appropriate instrumentation.
998
1004
  */
999
1005
  const wrapVercelLanguageModel = (model, phClient, options) => {
1006
+ const specificationVersion = getSpecificationVersion(model);
1007
+ if (specificationVersion !== 'v2' && specificationVersion !== 'v3') {
1008
+ throw new Error(`[PostHog AI] withTracing supports Vercel AI SDK v5 and v6 models only. ` + `Use @ai-sdk/otel with @posthog/ai/otel for AI SDK v7 models.`);
1009
+ }
1000
1010
  const traceId = options.posthogTraceId ?? v4();
1001
1011
  const mergedOptions = {
1002
1012
  ...options,