{"record":{"id":"ee676eac161e992d","repo":"vercel/ai","slug":"unsupported-model-version-options-version-for-p","errorCode":null,"errorMessage":"Unsupported model version ${options.version} for provider \"${options.provider}\" and model \"${options.modelId}\". AI SDK 5 only supports models that implement specification version \"v2\".","messagePattern":"Unsupported model version (.+?) for provider \"(.+?)\" and model \"(.+?)\"\\. AI SDK 5 only supports models that implement specification version \"v2\"\\.","errorType":"exception","errorClass":"UnsupportedModelVersionError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/model/resolve-model.ts","lineNumber":38,"sourceCode":"import { asImageModelV4 } from './as-image-model-v4';\nimport { asLanguageModelV4 } from './as-language-model-v4';\nimport { asRerankingModelV4 } from './as-reranking-model-v4';\nimport { asSpeechModelV4 } from './as-speech-model-v4';\nimport { asTranscriptionModelV4 } from './as-transcription-model-v4';\nimport { asVideoModelV4 } from './as-video-model-v4';\nimport { asProviderV4 } from './as-provider-v4';\nimport type { ImageModel } from '../types/image-model';\nimport type { RerankingModel } from '../types/reranking-model';\nimport type { VideoModel } from '../types/video-model';\n\nexport function resolveLanguageModel(model: LanguageModel): LanguageModelV4 {\n  if (typeof model === 'string') {\n    return getGlobalProvider().languageModel(model);\n  }\n\n  if (!['v4', 'v3', 'v2'].includes(model.specificationVersion)) {\n    const unsupportedModel: any = model;\n    throw new UnsupportedModelVersionError({\n      version: unsupportedModel.specificationVersion,\n      provider: unsupportedModel.provider,\n      modelId: unsupportedModel.modelId,\n    });\n  }\n\n  return asLanguageModelV4(model);\n}\n\nexport function resolveEmbeddingModel(model: EmbeddingModel): EmbeddingModelV4 {\n  if (typeof model === 'string') {\n    return getGlobalProvider().embeddingModel(model);\n  }\n\n  if (!['v4', 'v3', 'v2'].includes(model.specificationVersion)) {\n    const unsupportedModel: any = model;\n    throw new UnsupportedModelVersionError({\n      version: unsupportedModel.specificationVersion,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/model/resolve-model.ts#L20-L56","documentation":"resolveLanguageModel only accepts language models implementing specification versions v2, v3, or v4. Passing a model object with any other specificationVersion throws UnsupportedModelVersionError with the model's version, provider, and modelId. This catches incompatible custom/older model objects early.","triggerScenarios":"Passing a hand-built or legacy model object whose specificationVersion is not 'v2'/'v3'/'v4' into generateText, streamText, or any API that resolves a language model.","commonSituations":"Using a model instance created for an older AI SDK major version (e.g. AI SDK 4 model objects in AI SDK 5+); custom LanguageModel implementations not updated to a supported spec; mixing packages from mismatched @ai-sdk versions.","solutions":["Update the provider package to a version matching the installed ai package.","Replace legacy/custom model objects with models built by current @ai-sdk/<provider> packages.","Align all @ai-sdk/* package versions in your lockfile (pnpm dedupe / update).","If custom, update the model's specificationVersion and implementation to a supported spec (v2+)."],"exampleFix":"// before\nimport { oldModel } from 'legacy-provider'; // specificationVersion: 'v1'\nawait generateText({ model: oldModel, prompt });\n// after\nimport { createOpenAI } from '@ai-sdk/openai';\nconst openai = createOpenAI({ apiKey });\nawait generateText({ model: openai('gpt-4o'), prompt }); // spec v2+","handlingStrategy":"try-catch","validationCode":"function isSupportedLanguageModel(model) {\n  return ['v2', 'v3', 'v4'].includes(model?.specificationVersion);\n}\nif (!isSupportedLanguageModel(model)) throw new Error('unsupported model spec: ' + model?.specificationVersion);","typeGuard":"function isSupportedLanguageModel(model) {\n  return typeof model === 'object' && ['v2', 'v3', 'v4'].includes(model.specificationVersion);\n}","tryCatchPattern":"import { UnsupportedModelVersionError } from 'ai';\ntry {\n  await generateText({ model, prompt });\n} catch (e) {\n  if (UnsupportedModelVersionError.isInstance(e)) {\n    console.error(`Model ${e.modelId} from ${e.provider} uses spec ${e.version}; upgrade the provider package`);\n  }\n}","preventionTips":["Always build models with current @ai-sdk/<provider> factories.","Keep ai and @ai-sdk/* versions aligned (dedupe lockfile).","Avoid persisting/reusing model objects across major SDK upgrades.","Run type-checks to catch legacy model types."],"tags":["typescript","model-compatibility","version-mismatch"],"backgroundTag":"unsupported-model-version","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}