Asking an AI model to return information in a predefined format, such as JSON.
💡 Asking someone to fill out a standard form instead of writing an unstructured paragraph.
const res = await openai.chat.completions.create({
model: "gpt-4o",
response_format: { type: "json_object" },
messages: [{ role: "user", content: "Return {name, age} for Alice, 30" }],
});
console.log(JSON.parse(res.choices[0].message.content));It makes responses easier to consume programmatically and integrate into frontends, APIs and databases.
Structured output constrains the format, not the accuracy of the content.
with tapaScript
By clicking Sign Up you re confirming that you agree with our Terms and Conditions.
