vercel/ai · error · UnsupportedModelVersionError
Unsupported model version ${options.version} for provider "$
Error message
Unsupported model version ${options.version} for provider "${options.provider}" and model "${options.modelId}". AI SDK 5 only supports models that implement specification version "v2". What it means
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.
Source
Thrown at packages/ai/src/model/resolve-model.ts:38
import { asImageModelV4 } from './as-image-model-v4';
import { asLanguageModelV4 } from './as-language-model-v4';
import { asRerankingModelV4 } from './as-reranking-model-v4';
import { asSpeechModelV4 } from './as-speech-model-v4';
import { asTranscriptionModelV4 } from './as-transcription-model-v4';
import { asVideoModelV4 } from './as-video-model-v4';
import { asProviderV4 } from './as-provider-v4';
import type { ImageModel } from '../types/image-model';
import type { RerankingModel } from '../types/reranking-model';
import type { VideoModel } from '../types/video-model';
export function resolveLanguageModel(model: LanguageModel): LanguageModelV4 {
if (typeof model === 'string') {
return getGlobalProvider().languageModel(model);
}
if (!['v4', 'v3', 'v2'].includes(model.specificationVersion)) {
const unsupportedModel: any = model;
throw new UnsupportedModelVersionError({
version: unsupportedModel.specificationVersion,
provider: unsupportedModel.provider,
modelId: unsupportedModel.modelId,
});
}
return asLanguageModelV4(model);
}
export function resolveEmbeddingModel(model: EmbeddingModel): EmbeddingModelV4 {
if (typeof model === 'string') {
return getGlobalProvider().embeddingModel(model);
}
if (!['v4', 'v3', 'v2'].includes(model.specificationVersion)) {
const unsupportedModel: any = model;
throw new UnsupportedModelVersionError({
version: unsupportedModel.specificationVersion,View on GitHub (pinned to 69428b1f8b)
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+).
Example fix
// before
import { oldModel } from 'legacy-provider'; // specificationVersion: 'v1'
await generateText({ model: oldModel, prompt });
// after
import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI({ apiKey });
await generateText({ model: openai('gpt-4o'), prompt }); // spec v2+ Defensive patterns
Strategy: try-catch
Validate before calling
function isSupportedLanguageModel(model) {
return ['v2', 'v3', 'v4'].includes(model?.specificationVersion);
}
if (!isSupportedLanguageModel(model)) throw new Error('unsupported model spec: ' + model?.specificationVersion); Type guard
function isSupportedLanguageModel(model) {
return typeof model === 'object' && ['v2', 'v3', 'v4'].includes(model.specificationVersion);
} Try / catch
import { UnsupportedModelVersionError } from 'ai';
try {
await generateText({ model, prompt });
} catch (e) {
if (UnsupportedModelVersionError.isInstance(e)) {
console.error(`Model ${e.modelId} from ${e.provider} uses spec ${e.version}; upgrade the provider package`);
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported chunk type: ${_exhaustiveCheck}
- Unsupported chunk type: ${_exhaustiveCheck}
- Unknown chunk type: ${exhaustiveCheck}
- The provider does not support file uploads. Make sure it exp
- The provider does not support skills. Make sure it exposes a
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/ee676eac161e992d.
Report an issue: GitHub.