Provider workflows
OpenAI Strict Functions and Structured Output
Choose between Responses structured text and strict function calls, define constrained schemas, validate semantics, and keep execution under application control.
- Format
- Reference
- Level
- Intermediate
- Audience
- Developer, Operator
- Owner
- Project42 Editorial
- Review cadence
- Every 30 days
- Prerequisites
- A working Responses API request; An OpenAI model that supports the selected feature; A JSON Schema for the intended data
Choose the correct control
Use text.format with type json_schema when the model should return schema-constrained content to the user or application. Use a function tool when the model should request data or an application capability. Set strict: true and close the object schema with additionalProperties: false. Structure is not authorization, factual verification, or permission to execute.
The application—not the model—maps a function name to code. Authenticate and authorize with trusted runtime context, validate arguments again, obtain approval for consequential actions, use idempotency for mutations, and return a typed function_call_output tied to the original call ID.
Define an explicit Responses contract
The following request-body fragments show the current Responses API shapes. Insert one into a reviewed request and replace bracketed values with non-secret domain fields.
const structuredText = {
text: {
format: {
type: "json_schema",
name: "review_decision",
strict: true,
schema: {
type: "object",
properties: { decision: { type: "string", enum: ["approve", "review", "reject"] }, reason: { type: "string" } },
required: ["decision", "reason"],
additionalProperties: false,
},
},
},
};
const strictFunction = {
tools: [{
type: "function",
name: "record_review_decision",
description: "Record an already authorized review decision for [SYSTEM_OF_RECORD]",
strict: true,
parameters: {
type: "object",
properties: { item_id: { type: "string" }, decision: { type: "string", enum: ["approve", "reject"] } },
required: ["item_id", "decision"],
additionalProperties: false,
},
}],
};Expected evidence and verification
For structured text, expect output_text content that conforms to the named schema. For function calling, expect a function_call output item with a known name, call_id, and JSON arguments. Verify response status, refusal or incomplete outcomes, schema, enum values, length limits, authorization, and domain rules. Test valid, missing, extra, malformed, unauthorized, duplicate, refusal, and truncation cases.
Do not execute when parsing, validation, approval, or authorization fails. Record a redacted failure and request correction or human review within a retry budget. Rollback means discarding untrusted output; for an executed function, use its idempotency key and tested compensation or reconciliation path. Schema compliance never guarantees truth or safety.