Code QuizIntermediate Structured Output Constraint via Enum
Constraining a model's answer to a fixed set of labels using a JSON schema enum.
Codejavascript
const schema = {
type: "object",
properties: {
sentiment: {
type: "string",
enum: "positive, negative, neutral"
}
},
required: ["sentiment"]
};
await client.responses.create({
model: "gpt-4o-mini",
input: "Classify: 'I love this!'",
response_format: { type: "json_schema", json_schema: { name: "s", schema } }
});What is the bug in this schema definition?