{"record":{"id":"14dd449fca60090c","repo":"vercel/ai","slug":"invalid-argument-for-parameter-enumvalues-enum-va","errorCode":null,"errorMessage":"Invalid argument for parameter enumValues: Enum values are not supported for no-schema output.","messagePattern":"Invalid argument for parameter enumValues: Enum values are 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":57,"sourceCode":"\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,\n        message: 'Schema name is not supported for no-schema output.',\n      });\n    }\n\n    if (enumValues != null) {\n      throw new InvalidArgumentError({\n        parameter: 'enumValues',\n        value: enumValues,\n        message: 'Enum values are not supported for no-schema output.',\n      });\n    }\n  }\n\n  if (output === 'object') {\n    if (schema == null) {\n      throw new InvalidArgumentError({\n        parameter: 'schema',\n        value: schema,\n        message: 'Schema is required for object output.',\n      });\n    }\n\n    if (enumValues != null) {\n      throw new InvalidArgumentError({","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/validate-object-generation-input.ts#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ngenerateObject({ model, output: 'no-schema', enumValues: ['small','large'], prompt });\n// after\ngenerateObject({ model, output: 'enum', enumValues: ['small','large'], prompt });","handlingStrategy":"validation","validationCode":"if (opts.output === 'no-schema' && opts.enumValues != null) {\n  throw new Error(\"enumValues require output: 'enum'\");\n}","typeGuard":"function isEnumOnlyOptions(opts) {\n  return opts.enumValues != null ? opts.output === 'enum' : true;\n}","tryCatchPattern":"try {\n  await generateObject(opts);\n} catch (error) {\n  if (InvalidArgumentError.isInstance(error) && error.parameter === 'enumValues') {\n    const { enumValues, ...rest } = opts;\n    return generateObject({ ...rest, output: 'enum', enumValues });\n  }\n  throw error;\n}","preventionTips":["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."],"tags":["invalid-argument","enum-values","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"}