{"record":{"id":"4dfb3325798f80e9","repo":"vercel/ai","slug":"invalid-argument-for-parameter-schema-schema-is-n","errorCode":null,"errorMessage":"Invalid argument for parameter schema: Schema is not supported for no-schema output.","messagePattern":"Invalid argument for parameter schema: Schema is not supported for no-schema output\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-object/validate-object-generation-input.ts","lineNumber":33,"sourceCode":"  enumValues?: Array<unknown>;\n}) {\n  if (\n    output != null &&\n    output !== 'object' &&\n    output !== 'array' &&\n    output !== 'enum' &&\n    output !== 'no-schema'\n  ) {\n    throw new InvalidArgumentError({\n      parameter: 'output',\n      value: output,\n      message: 'Invalid output type.',\n    });\n  }\n\n  if (output === 'no-schema') {\n    if (schema != null) {\n      throw new InvalidArgumentError({\n        parameter: 'schema',\n        value: schema,\n        message: 'Schema is not supported for no-schema output.',\n      });\n    }\n\n    if (schemaDescription != null) {\n      throw new InvalidArgumentError({\n        parameter: 'schemaDescription',\n        value: schemaDescription,\n        message: 'Schema description is not supported for no-schema output.',\n      });\n    }\n\n    if (schemaName != null) {\n      throw new InvalidArgumentError({\n        parameter: 'schemaName',\n        value: schemaName,","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/validate-object-generation-input.ts#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ngenerateObject({ model, output: 'no-schema', schema: z.object({ name: z.string() }), prompt });\n// after\ngenerateObject({ model, output: 'no-schema', prompt });","handlingStrategy":"validation","validationCode":"function assertNoSchemaOptions(opts) {\n  if (opts.output === 'no-schema' && opts.schema != null) {\n    throw new Error(\"schema must be omitted when output is 'no-schema'\");\n  }\n}","typeGuard":"function isNoSchemaOptions(opts) {\n  return opts.output === 'no-schema' && opts.schema == null;\n}","tryCatchPattern":"try {\n  await generateObject({ model, output: 'no-schema', prompt });\n} catch (error) {\n  if (InvalidArgumentError.isInstance(error) && error.parameter === 'schema') {\n    // re-call without schema\n  }\n  throw error;\n}","preventionTips":["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."],"tags":["invalid-argument","schema","no-schema","input-validation"],"backgroundTag":"incompatible-schema-option","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}