vercel/ai · error · InvalidArgumentError
Invalid argument for parameter enumValues: Enum values are n
Error message
Invalid argument for parameter enumValues: Enum values are not supported for no-schema output.
What it means
enumValues powers enum-style output (output: 'enum'), where the model must pick one of the given values. Passing enumValues together with output: 'no-schema' is contradictory because no-schema output has no constrained value set, so InvalidArgumentError is thrown.
Source
Thrown at packages/ai/src/generate-object/validate-object-generation-input.ts:57
if (schemaDescription != null) {
throw new InvalidArgumentError({
parameter: 'schemaDescription',
value: schemaDescription,
message: 'Schema description is not supported for no-schema output.',
});
}
if (schemaName != null) {
throw new InvalidArgumentError({
parameter: 'schemaName',
value: schemaName,
message: 'Schema name is not supported for no-schema output.',
});
}
if (enumValues != null) {
throw new InvalidArgumentError({
parameter: 'enumValues',
value: enumValues,
message: 'Enum values are not supported for no-schema output.',
});
}
}
if (output === 'object') {
if (schema == null) {
throw new InvalidArgumentError({
parameter: 'schema',
value: schema,
message: 'Schema is required for object output.',
});
}
if (enumValues != null) {
throw new InvalidArgumentError({View on GitHub (pinned to 69428b1f8b)
Solutions
- Remove enumValues when using output: 'no-schema'.
- If the model should choose from fixed values, set output: 'enum' and keep enumValues.
- Constrain choices via prompt wording if you truly need free-form output.
Example fix
// before
generateObject({ model, output: 'no-schema', enumValues: ['small','large'], prompt });
// after
generateObject({ model, output: 'enum', enumValues: ['small','large'], prompt }); Defensive patterns
Strategy: validation
Validate before calling
if (opts.output === 'no-schema' && opts.enumValues != null) {
throw new Error("enumValues require output: 'enum'");
} Type guard
function isEnumOnlyOptions(opts) {
return opts.enumValues != null ? opts.output === 'enum' : true;
} Try / catch
try {
await generateObject(opts);
} catch (error) {
if (InvalidArgumentError.isInstance(error) && error.parameter === 'enumValues') {
const { enumValues, ...rest } = opts;
return generateObject({ ...rest, output: 'enum', enumValues });
}
throw error;
} Prevention
- Pair enumValues exclusively with output: 'enum'.
- Model free-form choice constraints in the prompt for no-schema output.
- Type your option unions so enumValues only exists on enum-mode options.
When it happens
Trigger: Calling generateObject({ model, output: 'no-schema', enumValues: ['a','b'], prompt }) or streamObject with the same; any non-null enumValues with no-schema output triggers it.
Common situations: Dynamic code that switches output mode but always includes enumValues; copy-pasted enum-generation call whose output field was changed to no-schema; generic wrapper building options for multiple output types.
Related errors
- Invalid argument for parameter schema: Schema is not support
- 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
- Invalid argument for parameter enumValues: Enum values are n
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/14dd449fca60090c.
Report an issue: GitHub.