{"record":{"id":"6a817f5dcc61a0d2","repo":"vercel/ai","slug":"message","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/ai/src/logger/log-warnings.ts","lineNumber":104,"sourceCode":"export const FIRST_WARNING_INFO_MESSAGE =\n  'AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.';\n\nlet hasLoggedBefore = false;\n\nfunction emitWarning({\n  message,\n  type,\n}: {\n  message: string;\n  type: 'DeprecationWarning' | 'Warning';\n}) {\n  if (\n    typeof process !== 'undefined' &&\n    typeof process.emitWarning === 'function'\n  ) {\n    process.emitWarning(message, { type });\n  } else {\n    console.warn(message);\n  }\n}\n\n/**\n * Logs warnings to the console or uses a custom logger if configured.\n *\n * The behavior can be customized via the `AI_SDK_LOG_WARNINGS` global variable:\n * - If set to `false`, warnings are suppressed.\n * - If set to a function, that function is called with the warnings.\n * - Otherwise, warnings are logged to the console using `console.warn`.\n *\n * @param options - The options containing warnings and context.\n * @param options.warnings - The warnings to log.\n * @param options.provider - The provider id used for the call, if scoped to a specific provider.\n * @param options.model - The model id used for the call, if scoped to a specific provider.\n */\nexport const logWarnings: LogWarningsFunction = options => {\n  // if the warnings array is empty, do nothing","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/logger/log-warnings.ts#L86-L122","documentation":"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).","triggerScenarios":"Any SDK warning being logged: calling APIs with deprecated options, unsupported model/provider settings, or other conditions the core package flags via logWarnings/emitWarning.","commonSituations":"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.","solutions":["Read the warning message and address the flagged condition (e.g. stop using the deprecated option)","Configure the SDK's custom logger (logger option) to route/route downlevel warnings appropriately","Ignore benign warnings only after confirming they do not indicate misconfiguration"],"exampleFix":"// before\nstreamText({ model, providerOptions: { unsupported: true } }); // warns\n// after\nstreamText({ model, providerOptions: supportedOptions });","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isSdkWarning(value: unknown): value is { message: string; type?: string } {\n  return typeof value === 'object' && value !== null && 'message' in value;\n}","tryCatchPattern":"process.on('warning', warning => {\n  if (warning.name === 'AI Warning') {\n    logger.debug({ warning: warning.message });\n  }\n});","preventionTips":["Set the SDK logger option to route warnings to your structured logger","Fix flagged conditions (deprecated/unsupported options) instead of suppressing warnings","Add CI checks that fail on new SDK warnings during upgrade"],"tags":["logging","warning","deprecation","node"],"backgroundTag":"sdk-deprecation-warning","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}