vercel/ai · error · InvalidArgumentError
Invalid argument for parameter schemaName: Schema name is no
Error message
Invalid argument for parameter schemaName: Schema name is not supported for enum output.
What it means
generateObject/streamObject in 'enum' output mode takes `enum` values instead of a named JSON schema, so passing a `schemaName` is invalid. validateObjectGenerationInput proactively rejects the combination with InvalidArgumentError before any model call. This prevents users from assuming a schema name is transmitted when it would be ignored or rejected.
Source
Thrown at packages/ai/src/generate-object/validate-object-generation-input.ts:119
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,
message: 'Schema name is not supported for enum output.',
});
}
if (enumValues == null) {
throw new InvalidArgumentError({
parameter: 'enumValues',
value: enumValues,
message: 'Enum values are required for enum output.',
});
}
for (const value of enumValues) {
if (typeof value !== 'string') {
throw new InvalidArgumentError({
parameter: 'enumValues',View on GitHub (pinned to 69428b1f8b)
Solutions
- Remove the schemaName property from the generateObject/streamObject call when using output: 'enum'
- Keep schemaName only for output: 'object' or 'array' calls where a JSON schema is provided
- Conditionally build the options object so schema-dependent fields are only set for schema-based modes
Example fix
// before
const { object } = await generateObject({
model, output: 'enum', enum: ['A','B'], schemaName: 'Choice'
});
// after
const { object } = await generateObject({
model, output: 'enum', enum: ['A','B']
}); Defensive patterns
Strategy: validation
Validate before calling
if (output === 'enum' && 'schemaName' in args && args.schemaName != null) {
throw new Error('schemaName is not allowed with output: enum');
} Type guard
function isEnumArgs(args: { output?: string; schemaName?: string }): boolean {
return args.output !== 'enum' || args.schemaName == null;
} Try / catch
try {
await generateObject(args);
} catch (e) {
if (InvalidArgumentError.isInstance(e) && e.parameter === 'schemaName') {
delete args.schemaName;
return generateObject(args);
}
throw e;
} Prevention
- Never mix schema/schemaName/schemaDescription with output: 'enum'
- Build options objects per output mode instead of sharing one
- Rely on TypeScript discriminated unions for the output options
When it happens
Trigger: Calling generateObject({ output: 'enum', enum: [...], schemaName: 'MyEnum' }) or the same with streamObject. Any non-null schemaName combined with output:'enum' triggers it.
Common situations: Refactoring code from a 'object'/'array' output mode (where schemaName is valid) to 'enum' mode and leaving schemaName in place; copy-pasted options objects shared between calls; older code predating the enum output mode.
Related errors
- Invalid argument for parameter enumValues: Enum values are r
- Invalid argument for parameter enumValues: Enum values must
- Invalid argument for parameter output: Invalid output type.
- Invalid argument for parameter schema: Schema is not support
- Invalid argument for parameter schemaDescription: Schema des
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/2b146f8deeffffcf.
Report an issue: GitHub.