Skip to main content
To get JSON back, set a format. json_object asks for any JSON object; json_schema asks for JSON that follows your schema. A json_schema format needs a name of 1 to 64 letters, digits, _ or -, and a schema object; strict and description are optional.

Chat Completions

Responses API

The same format goes in text.format, without the json_schema wrapper:

Parse safely

  • Check finish_reason (Responses: status) first. An answer that ended because of the output limit (length, or incomplete) isn’t complete JSON. Raise the limit or leave it unset.
  • The plan still comes first and counts toward the output limit; only the answer is JSON.
  • Validate the parsed object against your schema before you use it.
Last modified on December 5, 2026