vercel/ai · warning

${message}

Error message

${message}

What it means

This is a warning-emission path, not a thrown exception: `emitWarning` in log-warnings.ts surfaces SDK warning messages either via `process.emitWarning(message, { type })` (Node) or `console.warn` (other runtimes). The message text is whatever warning the SDK's logWarnings decided to emit (e.g. deprecations, unsupported settings).

Source

Thrown at packages/ai/src/logger/log-warnings.ts:104

export const FIRST_WARNING_INFO_MESSAGE =
  'AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.';

let hasLoggedBefore = false;

function emitWarning({
  message,
  type,
}: {
  message: string;
  type: 'DeprecationWarning' | 'Warning';
}) {
  if (
    typeof process !== 'undefined' &&
    typeof process.emitWarning === 'function'
  ) {
    process.emitWarning(message, { type });
  } else {
    console.warn(message);
  }
}

/**
 * Logs warnings to the console or uses a custom logger if configured.
 *
 * The behavior can be customized via the `AI_SDK_LOG_WARNINGS` global variable:
 * - If set to `false`, warnings are suppressed.
 * - If set to a function, that function is called with the warnings.
 * - Otherwise, warnings are logged to the console using `console.warn`.
 *
 * @param options - The options containing warnings and context.
 * @param options.warnings - The warnings to log.
 * @param options.provider - The provider id used for the call, if scoped to a specific provider.
 * @param options.model - The model id used for the call, if scoped to a specific provider.
 */
export const logWarnings: LogWarningsFunction = options => {
  // if the warnings array is empty, do nothing

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Read the warning message and address the flagged condition (e.g. stop using the deprecated option)
  2. Configure the SDK's custom logger (logger option) to route/route downlevel warnings appropriately
  3. Ignore benign warnings only after confirming they do not indicate misconfiguration

Example fix

// before
streamText({ model, providerOptions: { unsupported: true } }); // warns
// after
streamText({ model, providerOptions: supportedOptions });
Defensive patterns

Strategy: type-guard

Type guard

function isSdkWarning(value: unknown): value is { message: string; type?: string } {
  return typeof value === 'object' && value !== null && 'message' in value;
}

Try / catch

process.on('warning', warning => {
  if (warning.name === 'AI Warning') {
    logger.debug({ warning: warning.message });
  }
});

Prevention

When it happens

Trigger: Any SDK warning being logged: calling APIs with deprecated options, unsupported model/provider settings, or other conditions the core package flags via logWarnings/emitWarning.

Common situations: Using a deprecated API option; passing a setting the selected model does not support; running warnings through a logger that surfaces them as errors in monitoring.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/6a817f5dcc61a0d2. Report an issue: GitHub.