vercel/ai · error
`model` cannot be a string in `streamUI`. Use the actual mod
Error message
`model` cannot be a string in `streamUI`. Use the actual model instance instead.
What it means
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.
Source
Thrown at packages/rsc/src/stream-ui/stream-ui.tsx:180
value: ReactNode;
/**
* Warnings from the model provider (e.g. unsupported settings)
*/
warnings?: CallWarning[];
/**
* Optional response data.
*/
response?: {
/**
* Response headers.
*/
headers?: Record<string, string>;
};
}) => Promise<void> | void;
}): Promise<RenderResult> {
// TODO: Remove these errors after the experimental phase.
if (typeof model === 'string') {
throw new Error(
'`model` cannot be a string in `streamUI`. Use the actual model instance instead.',
);
}
if ('functions' in settings) {
throw new Error(
'`functions` is not supported in `streamUI`, use `tools` instead.',
);
}
if ('provider' in settings) {
throw new Error(
'`provider` is no longer needed in `streamUI`. Use `model` instead.',
);
}
if (tools) {
for (const [name, tool] of Object.entries(tools)) {
if ('render' in tool) {
throw new Error(
'Tool definition in `streamUI` should not have `render` property. Use `generate` instead. Found in tool: ' +View on GitHub (pinned to 69428b1f8b)
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
Example fix
// before
streamUI({ model: 'gpt-4o', prompt });
// after
import { openai } from '@ai-sdk/openai';
streamUI({ model: openai('gpt-4o'), prompt }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof model === 'string') throw new TypeError('streamUI requires a model instance, got a string'); Type guard
function isModelInstance(m: unknown) { return typeof m === 'object' && m !== null && 'doGenerate' in m; } Prevention
- 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
When it happens
Trigger: Calling streamUI({ model: '<some-string>', ... }) — the first validation checks `typeof model === 'string'` and throws immediately before any streaming starts.
Common situations: 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'.
Related errors
- `functions` is not supported in `streamUI`, use `tools` inst
- `provider` is no longer needed in `streamUI`. Use `model` in
- Tool definition in `streamUI` should not have `render` prope
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/2821f40679cf0cfc.
Report an issue: GitHub.