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 no-schema output.
What it means
generateObject/streamObject validate input consistency before calling a provider. When you pass output: 'no-schema' (or Output.noSchema()), the model returns free-form text with no structured constraints, so a schema contradicts the requested mode. The library throws InvalidArgumentError to fail fast rather than silently ignoring the schema.
Source
Thrown at packages/ai/src/generate-object/validate-object-generation-input.ts:33
enumValues?: Array<unknown>;
}) {
if (
output != null &&
output !== 'object' &&
output !== 'array' &&
output !== 'enum' &&
output !== 'no-schema'
) {
throw new InvalidArgumentError({
parameter: 'output',
value: output,
message: 'Invalid output type.',
});
}
if (output === 'no-schema') {
if (schema != null) {
throw new InvalidArgumentError({
parameter: 'schema',
value: schema,
message: 'Schema is not supported for no-schema output.',
});
}
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,View on GitHub (pinned to 69428b1f8b)
Solutions
- Remove the schema property from the generateObject/streamObject call when using output: 'no-schema'.
- If you actually want structured output, change output to 'object' (default) and keep the schema.
- If you only need a description for the model, move the guidance into the prompt instead of schema/schemaDescription.
Example fix
// before
generateObject({ model, output: 'no-schema', schema: z.object({ name: z.string() }), prompt });
// after
generateObject({ model, output: 'no-schema', prompt }); Defensive patterns
Strategy: validation
Validate before calling
function assertNoSchemaOptions(opts) {
if (opts.output === 'no-schema' && opts.schema != null) {
throw new Error("schema must be omitted when output is 'no-schema'");
}
} Type guard
function isNoSchemaOptions(opts) {
return opts.output === 'no-schema' && opts.schema == null;
} Try / catch
try {
await generateObject({ model, output: 'no-schema', prompt });
} catch (error) {
if (InvalidArgumentError.isInstance(error) && error.parameter === 'schema') {
// re-call without schema
}
throw error;
} Prevention
- Build call options conditionally: only include schema for 'object'/'array' output.
- Avoid spreading shared option objects into generateObject calls.
- Rely on TypeScript overloads so no-schema calls are not accepted with schema.
When it happens
Trigger: Calling generateObject({ model, output: 'no-schema', schema: someZodSchema, prompt }) or the same with streamObject, or passing schema alongside Output.noSchema(). Any non-null schema value (including an empty object schema) triggers it.
Common situations: Refactoring a previously schema-based call to no-schema output but leaving the old schema option in place; spreading a shared options object that contains schema; switching from generateText to generateObject for unrestricted output while keeping schema.
Related errors
- 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 schema: Schema is not support
- Invalid argument for parameter schema: Schema is required fo
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/4dfb3325798f80e9.
Report an issue: GitHub.