vercel/ai · error · InvalidArgumentError
Invalid argument for parameter schema: Schema is not support
Error message
Invalid argument for parameter schema: Schema is not supported for enum output.
What it means
output: 'enum' makes the model select one value from enumValues; it does not use a schema. Passing schema (or an enum zod schema) with enum output is contradictory, so the library throws InvalidArgumentError.
Source
Thrown at packages/ai/src/generate-object/validate-object-generation-input.ts:103
throw new InvalidArgumentError({
parameter: 'schema',
value: schema,
message: 'Element schema is required for array output.',
});
}
if (enumValues != null) {
throw new InvalidArgumentError({
parameter: 'enumValues',
value: enumValues,
message: 'Enum values are not supported for array output.',
});
}
}
if (output === 'enum') {
if (schema != null) {
throw new InvalidArgumentError({
parameter: 'schema',
value: schema,
message: 'Schema is not supported for enum output.',
});
}
if (schemaDescription != null) {
throw new InvalidArgumentError({
parameter: 'schemaDescription',
value: schemaDescription,
message: 'Schema description is not supported for enum output.',
});
}
if (schemaName != null) {
throw new InvalidArgumentError({
parameter: 'schemaName',
value: schemaName,View on GitHub (pinned to 69428b1f8b)
Solutions
- Remove the schema property and keep only enumValues with output: 'enum'.
- If a schema is what you need (e.g. z.enum field inside an object), use output: 'object' instead.
- Update helpers/wrappers to conditionally attach schema only for object/array output.
Example fix
// before
generateObject({ model, output: 'enum', enumValues: ['a','b'], schema: z.enum(['a','b']), prompt });
// after
generateObject({ model, output: 'enum', enumValues: ['a','b'], prompt }); Defensive patterns
Strategy: validation
Validate before calling
if (opts.output === 'enum' && opts.schema != null) {
throw new Error("schema must be omitted when output is 'enum'; use enumValues");
} Type guard
function isEnumOptionsValid(opts) {
return opts.output !== 'enum' || (opts.schema == null && opts.enumValues != null);
} Try / catch
try {
return await generateObject(opts);
} catch (error) {
if (InvalidArgumentError.isInstance(error) && error.parameter === 'schema' && opts.output === 'enum') {
const { schema, ...rest } = opts;
return generateObject(rest);
}
throw error;
} Prevention
- With output: 'enum', specify enumValues only; drop schema and z.enum schemas.
- Use output: 'object' if you want the value embedded in a structured object.
- Conditionally build options per output mode in helper functions.
When it happens
Trigger: Calling generateObject({ model, output: 'enum', enumValues: [...], schema: someSchema, prompt }) or streamObject with schema set alongside enum output; any non-null schema with output: 'enum' triggers it.
Common situations: Previously passing a z.enum(...) schema and then also adding output: 'enum'/enumValues during migration; shared helper that always attaches schema; copy-pasted object-output code changed to enum output.
Related errors
- Invalid argument for parameter schema: Schema is not support
- Invalid argument for parameter schemaDescription: Schema des
- Invalid argument for parameter schemaDescription: Schema des
- Invalid argument for parameter schemaName: Schema name is no
- Invalid argument for parameter enumValues: Enum values are n
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/f121edd2a0cef2cb.
Report an issue: GitHub.