vercel/ai · error · UnsupportedFunctionalityError

'element streams in no-schema mode' functionality not suppor

Error message

'element streams in no-schema mode' functionality not supported.

What it means

This UnsupportedFunctionalityError is thrown by the no-schema output strategy when code asks for an element stream (`elementStream` on a streamObject result). Element streaming — emitting individual validated array elements as they complete — is only implemented for `output: 'array'` mode, so the no-schema strategy deliberately refuses it. The library throws early rather than silently returning an empty or undefined stream.

Source

Thrown at packages/ai/src/generate-object/output-strategy.ts:97

      finishReason: FinishReason;
    },
  ): Promise<ValidationResult<JSONValue>> {
    return value === undefined
      ? {
          success: false,
          error: new NoObjectGeneratedError({
            message: 'No object generated: response did not match schema.',
            text: context.text,
            response: context.response,
            usage: context.usage,
            finishReason: context.finishReason,
          }),
        }
      : { success: true, value };
  },

  createElementStream() {
    throw new UnsupportedFunctionalityError({
      functionality: 'element streams in no-schema mode',
    });
  },
};

const objectOutputStrategy = <OBJECT>(
  schema: Schema<OBJECT>,
): OutputStrategy<DeepPartial<OBJECT>, OBJECT, never> => ({
  type: 'object',
  jsonSchema: async () => await schema.jsonSchema,

  async validatePartialResult({ value, textDelta }) {
    return {
      success: true,
      value: {
        // Note: currently no validation of partial results:
        partial: value as DeepPartial<OBJECT>,
        textDelta,

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Switch to `output: 'array'` with an element schema if you need `elementStream`.
  2. Consume `partialObjectStream` or `textStream` instead of `elementStream` when using `output: 'no-schema'`.
  3. Remove `as any` / untyped wrappers so TypeScript's type on the streamObject result prevents accessing `elementStream` in no-schema mode.

Example fix

// before
const result = streamObject({ model, prompt, output: 'no-schema' });
for await (const element of result.elementStream) { ... }

// after
const result = streamObject({ model, prompt, output: 'array', schema: z.object({ name: z.string() }) });
for await (const element of result.elementStream) { ... }
Defensive patterns

Strategy: type-guard

Validate before calling

// check mode before touching elementStream
function supportsElementStream(result: unknown): boolean {
  return typeof result === 'object' && result !== null && 'elementStream' in result;
}
// only call streamObject with output:'array' if you plan to read elementStream

Type guard

function isArrayModeOutput(output: unknown): output is 'array' {
  return output === 'array';
}

Try / catch

try {
  for await (const el of result.elementStream) { /* ... */ }
} catch (e) {
  if (UnsupportedFunctionalityError.isInstance(e)) {
    // fall back to result.partialObjectStream or textStream
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `streamObject({ output: 'no-schema', ... })` and then consuming `result.elementStream`. TypeScript usually prevents this at compile time, but it occurs when types are cast/erased (e.g. `as any`), when result objects are passed through untyped wrappers, or when running older JS that bypasses the type system.

Common situations: Developers migrating from `output: 'array'` to `output: 'no-schema'` (to skip schema validation) but still consuming `elementStream`; dynamic code that selects output mode at runtime while always reading `elementStream`; loosely typed JavaScript callers.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/40de72a0863a2862. Report an issue: GitHub.