SCHEMA CONFIGURATION
What are Structured Outputs in LLMs?
When integrating Large Language Models (LLMs) into production software, developers need to receive responses in a structured format (such as JSON) rather than unstructured free-form text. Structured data allows downstream application systems to reliably parse key-value properties without worrying about formatting discrepancies or missing attributes.
Modern APIs (such as OpenAI’s GPT-4o, Anthropic Claude Tool Use, and Google Gemini Structured Outputs) enforce this output format by taking a developer-defined JSON Schema as a parameter, forcing the model to align its tokens exactly to the specified JSON blueprint.
Understanding OpenAI’s Strict Schema Rules
Under OpenAI’s "strict": true response format configuration, the API guarantees that the model will conform 100% to the provided JSON Schema. However, to support this strict guarantee, OpenAI imposes several configuration constraints on the JSON Schema structure:
- No Additional Properties: Every object schema definition must explicitly include the property
"additionalProperties": false. This prevents the LLM from adding hallucinated keys that were not defined in the schema. - Complete Required Arrays: Every key defined inside the
"properties"block of an object must also be listed in the object’s"required"array. Even optional parameters must be listed in the required list, utilizing nullable type definitions (e.g.["string", "null"]) to represent optionality. - Constraint Limitations: Certain draft-2020-12 validations (like string length constraints or number value ranges) are not supported by the strict parser.
Our compiler handles these rules automatically, compiling any pasted JSON payload into a strict, compliant schema wrapper ready for direct copy-pasting into your API calls.
How to Integrate Structured Outputs in Python and JavaScript
Once you compile your schema, you can easily integrate it into your codebases using standard SDK structures:
1. Python Integration (Using Pydantic)
OpenAI’s Python SDK supports parsing schemas automatically from Pydantic classes compiled in the Pydantic tab of this tool:
from openai import OpenAI
from pydantic import BaseModel
class UserProfile(BaseModel):
id: int
name: str
email: str
client = OpenAI()
completion = client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
messages=[
{"role": "system", "value": "Extract user info."},
{"role": "user", "value": "John Doe can be reached at john@example.com"}
],
response_format=UserProfile,
)
user_data = completion.choices[0].message.parsed
print(user_data.name) # Output: John Doe
2. Node.js/JavaScript Integration (Using Zod)
For Node.js backends or TypeScript runtimes, you can use the Zod schema configuration generated by this tool:
import OpenAI from "openai";
import { z } from "zod";
import { zodResponseFormat } from "openai/helpers/zod";
const UserProfileSchema = z.object({
id: z.number(),
name: z.string(),
email: z.string()
}).strict();
const openai = new OpenAI();
const completion = await openai.beta.chat.completions.parse({
model: "gpt-4o-2024-08-06",
messages: [
{ role: "system", content: "Extract user info." },
{ role: "user", content: "John Doe can be reached at john@example.com" }
],
response_format: zodResponseFormat(UserProfileSchema, "user_profile"),
});
const user_data = completion.choices[0].message.parsed;
console.log(user_data.name); // Output: John Doe
Frequently Asked Questions (FAQ)
Q: Why does strict mode require setting additionalProperties to false?
A: Enabling this constraint tells the LLM’s parsing grammar that it cannot generate any key outside the defined schema. During the token selection process, the model is mathematically constrained from choosing any token that would represent a custom key, ensuring output structure compliance.
Q: Can I use this compiler for non-OpenAI models like Anthropic Claude or Gemini?
A: Yes! Standard JSON Schema generated in the first tab is compatible with Anthropic Claude’s Tool Use specification and Google Gemini’s `responseSchema` parameters. The schemas follow the standard Draft-07 specification.
Q: Is my data safe when pasting configurations here?
A: Absolutely. The RTSALL JSON Schema Compiler compiles all data structures locally inside your web browser using client-side JavaScript. No information is transmitted to external servers, making it completely secure for sensitive database structures and developer payloads.
![]()