vercel/ai · error · UnsupportedFunctionalityError
' ' functionality not supported.
Error message
'${functionality}' functionality not supported. What it means
streamText throws an UnsupportedFunctionalityError when you access the `elementStream` property but the configured output specification does not support element streams (its createElementStreamTransform returns null). Element streams are only available for output specifications that define per-element streaming (e.g. array/partial-object style outputs); in plain 'text' mode there is no element concept, so the stream cannot be created. The error names the mode so you can see which output configuration lacks the feature.
Solutions
- Configure streamText with an output specification that supports element streams (e.g. an array Output) before reading elementStream.
- If you only need full text, read `result.textStream` instead of `result.elementStream`.
- If you need a structured object (not streamed element-by-element), use `result.output`/object stream consumption instead of elementStream.
- Check `this.outputSpecification`/mode at runtime and branch to the correct stream accessor.
Example fix
// before
const result = streamText({ model, prompt });
for await (const element of result.elementStream) { ... }
// after
const result = streamText({
model,
prompt,
experimental_output: Output.array(Output.string()),
});
for await (const element of result.elementStream) { ... } Defensive patterns
Strategy: validation
Validate before calling
const supportsElements =
outputSpecification != null &&
typeof outputSpecification.createElementStreamTransform === 'function';
if (!supportsElements) {
// consume result.textStream or result.output instead of elementStream
} Type guard
function supportsElementStream(spec: unknown): spec is { createElementStreamTransform: () => unknown } {
return (
typeof spec === 'object' && spec !== null &&
'createElementStreamTransform' in spec &&
typeof (spec as any).createElementStreamTransform === 'function'
);
} Try / catch
try {
for await (const el of result.elementStream) handle(el);
} catch (error) {
if (UnsupportedFunctionalityError.isInstance(error)) {
for await (const text of result.textStream) handleText(text); // fallback
} else throw error;
} Prevention
- Only access elementStream when you configured an element-capable output specification.
- Gate stream selection on your own config flag, not on the result shape.
- Add a unit test that exercises elementStream for every output mode you ship.
When it happens
Trigger: Accessing `result.elementStream` on the DefaultStreamTextResult returned by streamText when no outputSpecification is set (default 'text' mode) or when using an output specification that does not implement createElementStreamTransform.
Common situations: Copying example code that iterates elementStream into a project that calls streamText without `experimental_output`/output configuration; using an output mode (e.g. plain text or object output) that predates or lacks element streaming support; upgrading the SDK and switching output specs without updating the consumption code.
Related errors
- Chunking must be "word", "line", a RegExp, an…
- AbortError
- ACP authentication and session profile settings cannot…
- ACP authentication method
- ACP credentialEnv and credentialBrokering must be…
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/66f31a0449209619.
Report an issue: GitHub.
Appendix: source
Thrown at packages/ai/src/generate-text/stream-text.ts:2897
new TransformStream<
EnrichedStreamPart<TOOLS, InferPartialOutput<OUTPUT>>,
InferPartialOutput<OUTPUT>
>({
transform({ partialOutput }, controller) {
if (partialOutput != null) {
controller.enqueue(partialOutput);
}
},
}),
),
);
}
get elementStream(): AsyncIterableStream<InferElementOutput<OUTPUT>> {
const transform = this.outputSpecification?.createElementStreamTransform();
if (transform == null) {
throw new UnsupportedFunctionalityError({
functionality: `element streams in ${
this.outputSpecification?.name ?? 'text'
} mode`,
});
}
return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
}
private getOutputPromise(): Promise<InferCompleteOutput<OUTPUT>> {
if (this.outputPromise == null) {
this.outputPromise = this.finalStep.then(step => {
const output = this.outputSpecification ?? text();
return output.parseCompleteOutput(
{ text: step.text },
{
response: step.response,
usage: step.usage,View on GitHub (pinned to 69428b1f8b)