Implementation:Openai Openai python Response Format Text JSON Schema
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete response type representing a JSON Schema response format configuration for Structured Outputs, provided by the openai-python SDK.
Description
ResponseFormatTextJSONSchemaConfig is a Pydantic model representing a JSON Schema response format used to generate structured JSON responses. It contains a name field (alphanumeric with underscores/dashes, max 64 characters), a schema_ field (aliased from "schema" in JSON) holding the JSON Schema object, a fixed type of "json_schema", an optional description for the model, and an optional strict flag to enforce strict schema adherence. When strict is true, only a subset of JSON Schema is supported. This type is auto-generated from the OpenAI OpenAPI specification by Stainless.
Usage
Import ResponseFormatTextJSONSchemaConfig when inspecting the response format configuration of a completed response that used Structured Outputs with a JSON schema.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/response_format_text_json_schema_config.py
Signature
class ResponseFormatTextJSONSchemaConfig(BaseModel):
"""JSON Schema response format. Used to generate structured JSON responses."""
name: str
schema_: Dict[str, object] = FieldInfo(alias="schema")
type: Literal["json_schema"]
description: Optional[str] = None
strict: Optional[bool] = None
Import
from openai.types.responses import ResponseFormatTextJSONSchemaConfig
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| name | str |
Yes | The name of the response format. Must be a-z, A-Z, 0-9, underscores, or dashes (max 64 characters). |
| schema_ | Dict[str, object] |
Yes | The JSON Schema object describing the response format. Aliased from "schema" in JSON.
|
| type | Literal["json_schema"] |
Yes | The type of response format. Always "json_schema".
|
| description | Optional[str] |
No | A description of the response format, used by the model to determine how to respond. |
| strict | Optional[bool] |
No | Whether to enable strict schema adherence. Only a subset of JSON Schema is supported when true.
|
Usage Examples
from openai.types.responses import ResponseFormatTextJSONSchemaConfig
# Inspect JSON schema format on a completed response
response = client.responses.create(
model="gpt-4o",
input="Extract the name and age from: John is 30 years old",
text={
"format": {
"type": "json_schema",
"name": "person_info",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name", "age"],
},
"strict": True,
}
},
)
# The response text config will be a ResponseFormatTextJSONSchemaConfig
print(response.text.format.name) # "person_info"
print(response.text.format.strict) # True