vercel/ai · error · UnsupportedFunctionalityError
'element streams in enum mode' functionality not supported.
Error message
'element streams in enum mode' functionality not supported.
What it means
The enum output strategy throws this UnsupportedFunctionalityError because there is no streaming of elements in `output: 'enum'` mode — the result is a single string chosen from a fixed list, so an element stream is meaningless. `streamObject` with enum output exposes `textStream`/`partialObjectStream`, but `elementStream` is explicitly unsupported.
Source
Thrown at packages/ai/src/generate-object/output-strategy.ts:396
value,
cause: 'value must be a string in the enum',
}),
};
}
return {
success: true,
value: {
partial:
possibleEnumValues.length > 1 ? result : possibleEnumValues[0],
textDelta,
},
};
},
createElementStream() {
// no streaming in enum mode
throw new UnsupportedFunctionalityError({
functionality: 'element streams in enum mode',
});
},
};
};
export function getOutputStrategy<SCHEMA>({
output,
schema,
enumValues,
}: {
output: 'object' | 'array' | 'enum' | 'no-schema';
schema?: FlexibleSchema<SCHEMA>;
enumValues?: Array<SCHEMA>;
}): OutputStrategy<any, any, any> {
switch (output) {
case 'object':
return objectOutputStrategy(asSchema(schema!));View on GitHub (pinned to 69428b1f8b)
Solutions
- For enum mode, await `result.object` or consume `textStream`/`partialObjectStream` instead of `elementStream`.
- If you truly need streamed elements, switch to `output: 'array'` with a string enum schema for elements.
- Gate any `elementStream` access behind `output === 'array'` in generic code.
Example fix
// before
const result = streamObject({ model, prompt, output: 'enum', enumValues: ['a','b'] });
for await (const el of result.elementStream) { ... }
// after
const result = streamObject({ model, prompt, output: 'enum', enumValues: ['a','b'] });
const choice = await result.object; // 'a' | 'b' Defensive patterns
Strategy: validation
Validate before calling
// only request elementStream in array mode
if (options.output !== undefined && options.output !== 'array') {
throw new Error('elementStream requires output: "array"');
} Type guard
function isEnumMode(o: unknown): o is 'enum' {
return o === 'enum';
} Try / catch
try {
for await (const el of result.elementStream) { /* ... */ }
} catch (e) {
if (UnsupportedFunctionalityError.isInstance(e)) {
const value = await result.object; // enum result is a single string
} else throw e;
} Prevention
- For enum mode, await result.object — never elementStream.
- Gate elementStream access on output === 'array' in generic code.
- Keep streamObject results typed to surface this at compile time.
- Switch to output:'array' with a z.enum element schema if streaming values matters.
When it happens
Trigger: Calling `streamObject({ output: 'enum', enumValues: [...], ... })` and then consuming `result.elementStream`, typically via untyped code, `as any` casts, or generic wrappers that unconditionally read `elementStream`.
Common situations: Classification tasks using enum output where a developer reuses array-streaming iteration code; runtime-polymorphic stream handlers that branch on stream shape without checking output mode.
Related errors
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
- streaming transcription with ${this.modelId}
- non-streaming transcription with ${this.modelId}
- streaming transcription with ${this.modelId}
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/7e82d56fa258d9e2.
Report an issue: GitHub.