{"record":{"id":"8345bc91bdfe4633","repo":"mastra-ai/mastra","slug":"agent-stream-v1-model-not-supported","errorCode":"AGENT_STREAM_V1_MODEL_NOT_SUPPORTED","errorMessage":"Agent \"${this.name}\" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with stream(). Please use AI SDK v5+ models or call the streamLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.","messagePattern":"Agent \"(.+?)\" is using AI SDK v4 model \\((.+?):(.+?)\\) which is not compatible with stream\\(\\)\\. Please use AI SDK v5\\+ models or call the streamLegacy\\(\\) method instead\\. See https://mastra\\.ai/en/docs/streaming/overview for more information\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":8642,"sourceCode":"      requestContext: mergedOptions.requestContext,\n      memory: mergedOptions.memory,\n      runId: mergedOptions.runId,\n      actor,\n    });\n\n    const llm = await this.getLLM({\n      requestContext: mergedOptions.requestContext,\n      model: mergedOptions.model as DynamicArgument<MastraModelConfig, TRequestContext> | undefined,\n    });\n\n    const modelInfo = llm.getModel();\n\n    if (!isSupportedLanguageModel(modelInfo)) {\n      const modelId = modelInfo.modelId || 'unknown';\n      const provider = modelInfo.provider || 'unknown';\n      const specVersion = modelInfo.specificationVersion;\n\n      throw new MastraError({\n        id: 'AGENT_STREAM_V1_MODEL_NOT_SUPPORTED',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text:\n          specVersion === 'v1'\n            ? `Agent \"${this.name}\" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with stream(). Please use AI SDK v5+ models or call the streamLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`\n            : `Agent \"${this.name}\" has a model (${provider}:${modelId}) with unrecognized specificationVersion \"${specVersion}\". Supported versions: v1 (legacy), v2 (AI SDK v5), v3 (AI SDK v6). Please ensure your AI SDK provider is compatible with this version of Mastra.`,\n        details: {\n          agentName: this.name,\n          modelId,\n          provider,\n          specificationVersion: specVersion,\n        },\n      });\n    }\n\n    const threadStreamPubSub = this.getPubSub();\n    mergedOptions.runId ??=","sourceCodeStart":8624,"sourceCodeEnd":8660,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L8624-L8660","documentation":"Agent.stream() only supports AI SDK v5 (LanguageModelV2) models. When the resolved model has specificationVersion 'v1' (AI SDK v4), Mastra throws AGENT_STREAM_V1_MODEL_NOT_SUPPORTED and points you to AI SDK v5 models or the streamLegacy() method. This mirrors the generate() check but for the streaming path.","triggerScenarios":"Calling agent.stream() where isSupportedLanguageModel(modelInfo) fails with specificationVersion === 'v1' — i.e. an AI SDK v4 model instance was passed or resolved from the model config.","commonSituations":"Using @ai-sdk/openai@0.x (v1 spec) with current Mastra; custom LangChain-bridged or wrapped providers pinned to v1; partial upgrades where generate was migrated to v5 models but stream still resolves an old model.","solutions":["Upgrade the AI SDK provider package so the model reports specificationVersion 'v2'.","Switch the call to agent.streamLegacy() if you must keep the v4 model.","Audit custom model wrappers to ensure they emit the v2 spec."],"exampleFix":"// before\nimport { openai } from '@ai-sdk/openai@0.x';\nawait agent.stream('hi');\n// after\nimport { openai } from '@ai-sdk/openai';\nawait agent.stream('hi'); // or agent.streamLegacy('hi') with the v4 model","handlingStrategy":"validation","validationCode":"const modelInfo = await resolveModelInfo(model);\nif (modelInfo?.specificationVersion === 'v1') {\n  throw new Error('Use agent.streamLegacy() for AI SDK v4 models');\n}","typeGuard":"function isV2Model(m: unknown): m is LanguageModelV2 {\n  return typeof m === 'object' && m !== null && (m as any).specificationVersion === 'v2';\n}","tryCatchPattern":"try {\n  await agent.stream(prompt);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_STREAM_V1_MODEL_NOT_SUPPORTED') {\n    return agent.streamLegacy(prompt);\n  }\n  throw e;\n}","preventionTips":["Upgrade AI SDK providers to v5-compatible versions.","Check model spec version once in your model factory.","Audit stream code paths separately from generate when migrating models."],"tags":["ai-sdk","version-mismatch","agent","streaming"],"backgroundTag":"incompatible-model-specification-version","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}