{"record":{"id":"2821f40679cf0cfc","repo":"vercel/ai","slug":"model-cannot-be-a-string-in-streamui-use-the","errorCode":null,"errorMessage":"`model` cannot be a string in `streamUI`. Use the actual model instance instead.","messagePattern":"`model` cannot be a string in `streamUI`\\. Use the actual model instance instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/rsc/src/stream-ui/stream-ui.tsx","lineNumber":180,"sourceCode":"      value: ReactNode;\n      /**\n       * Warnings from the model provider (e.g. unsupported settings)\n       */\n      warnings?: CallWarning[];\n      /**\n       * Optional response data.\n       */\n      response?: {\n        /**\n         * Response headers.\n         */\n        headers?: Record<string, string>;\n      };\n    }) => Promise<void> | void;\n  }): Promise<RenderResult> {\n  // TODO: Remove these errors after the experimental phase.\n  if (typeof model === 'string') {\n    throw new Error(\n      '`model` cannot be a string in `streamUI`. Use the actual model instance instead.',\n    );\n  }\n  if ('functions' in settings) {\n    throw new Error(\n      '`functions` is not supported in `streamUI`, use `tools` instead.',\n    );\n  }\n  if ('provider' in settings) {\n    throw new Error(\n      '`provider` is no longer needed in `streamUI`. Use `model` instead.',\n    );\n  }\n  if (tools) {\n    for (const [name, tool] of Object.entries(tools)) {\n      if ('render' in tool) {\n        throw new Error(\n          'Tool definition in `streamUI` should not have `render` property. Use `generate` instead. Found in tool: ' +","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/rsc/src/stream-ui/stream-ui.tsx#L162-L198","documentation":"streamUI in the experimental RSC API requires a real LanguageModelV1 instance for its `model` option. Passing a provider string id (like 'openai:gpt-4'), which older versions of the underlying streamText accepted, is rejected with this error during the experimental phase.","triggerScenarios":"Calling streamUI({ model: '<some-string>', ... }) — the first validation checks `typeof model === 'string'` and throws immediately before any streaming starts.","commonSituations":"Migrating code from an older API where model ids were strings; copying generateText examples that use provider id strings; misunderstanding provider options like `openai('gpt-4')` (an instance) vs the raw string 'gpt-4'.","solutions":["Create a model instance via a provider function, e.g. openai('gpt-4o'), and pass that to streamUI","Import the provider package (@ai-sdk/openai, @ai-sdk/anthropic, ...) and use its model factory","Remove any string-based model id configuration"],"exampleFix":"// before\nstreamUI({ model: 'gpt-4o', prompt });\n// after\nimport { openai } from '@ai-sdk/openai';\nstreamUI({ model: openai('gpt-4o'), prompt });","handlingStrategy":"validation","validationCode":"if (typeof model === 'string') throw new TypeError('streamUI requires a model instance, got a string');","typeGuard":"function isModelInstance(m: unknown) { return typeof m === 'object' && m !== null && 'doGenerate' in m; }","tryCatchPattern":null,"preventionTips":["Always create models with provider factories: openai('gpt-4o')","Never pass provider id strings from config files directly as model","Type the model param as LanguageModelV1 so strings fail at compile time"],"tags":["api-misuse","migration","model-instance"],"backgroundTag":"invalid-model-parameter","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}