mastra-ai/mastra · error · Error

Unsupported model version: ${(currentStep.model as { specifi

Error message

Unsupported model version: ${(currentStep.model as { specificationVersion?: string }).specificationVersion}. Supported versions: ${supportedLanguageModelSpecifications.join(', ')}

What it means

The agentic LLM execution step only supports models implementing the known AI SDK LanguageModelV specification versions (supportedLanguageModelSpecifications). If currentStep.model.specificationVersion is not one of them, the step throws a plain Error listing the supported versions. This happens when a model object from an incompatible AI SDK/provider version is passed.

Source

Thrown at packages/core/src/loop/workflows/agentic-execution/llm-execution-step.ts:1780

                    messageId: currentStep.messageId,
                  });

                  return {
                    runId,
                    from: ChunkFrom.AGENT,
                    type: 'step-start',
                    payload: {
                      request: request || {},
                      warnings: warnings || [],
                      messageId: currentStep.messageId,
                    },
                  };
                },
                shouldThrowError: !isLastModel,
              }),
          });
        } else {
          throw new Error(
            `Unsupported model version: ${(currentStep.model as { specificationVersion?: string }).specificationVersion}. Supported versions: ${supportedLanguageModelSpecifications.join(', ')}`,
          );
        }

        const outputStream = new MastraModelOutput<OUTPUT>({
          model: {
            modelId: currentStep.model.modelId,
            provider: currentStep.model.provider,
            version: currentStep.model.specificationVersion,
          },
          stream: modelResult as ReadableStream<ChunkType<OUTPUT>>,
          messageList,
          messageId: currentStep.messageId,
          options: {
            runId,
            toolCallStreaming,
            includeRawChunks,
            structuredOutput: currentStep.structuredOutput,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Upgrade or downgrade the provider package (@ai-sdk/openai, @ai-sdk/anthropic, etc.) so its specificationVersion matches the versions listed in the error message.
  2. Upgrade @mastra/core (and @mastra/ai-sdk integration) so it supports the model's specificationVersion.
  3. If using a custom model, implement the required LanguageModelV specification version interface.
  4. Log/inspect model.specificationVersion at workflow construction to catch the mismatch early.

Example fix

// before
import { generate } from 'ai@v4'; // model.specificationVersion = 'v1'
const workflow = createWorkflow(...).then(agentStep({ model: openai('gpt-4o') }));
// after
pnpm add @ai-sdk/openai@^2 ai@^5  // model.specificationVersion = 'v2'
const workflow = createWorkflow(...).then(agentStep({ model: openai('gpt-4o') }));
Defensive patterns

Strategy: validation

Validate before calling

const supported = ['v1','v2']; // see supportedLanguageModelSpecifications for your @mastra/core version
const model = await resolveModel(step.model);
if (!supported.includes(model.specificationVersion)) {
  throw new Error(`Model spec ${model.specificationVersion} unsupported; upgrade provider packages`);
}

Type guard

function isSupportedLanguageModel(m: unknown): m is { specificationVersion: string; doGenerate: Function } {
  return !!m && typeof m === 'object' && ['v1','v2'].includes((m as any).specificationVersion) && typeof (m as any).doGenerate === 'function';
}

Try / catch

try {
  await workflow.start({ inputData });
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Unsupported model version:')) {
    console.error('Fix @ai-sdk/provider package versions to match Mastra core');
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing a model instance whose specificationVersion (e.g. 'v1' vs 'v2'/'v3') does not match the AI SDK version bundled with this Mastra core — typically via agent.model, a workflow step's model, or dynamic model resolution returning a raw provider model built against a mismatched @ai-sdk/* major.

Common situations: Mixing @ai-sdk/provider v1-based models with an AI SDK v5-based Mastra (or vice versa); constructing a custom LanguageModel wrapper with a stale specificationVersion; passing a provider string resolved to an incompatible gateway model; duplicate model entries in a fallback chain where one model is on the wrong spec (note shouldThrowError/!isLastModel handling just above).

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/cf1237697938cdbd. Report an issue: GitHub.