Structured Output
Structured output lets you enforce a JSON schema on the LLM’s response. Instead of free-form text, the agent returns validated, typed data—ideal for sentiment analysis, entity extraction, form filling, and API integrations.What is Structured Output?
With structured output, you define a Zod schema that describes the expected shape of the response. RadarOS:- Converts the schema to a provider-specific format (e.g.,
json_schemafor OpenAI) - Instructs the LLM to respond in that format
- Parses and validates the response against the schema
- Exposes the result in
RunOutput.structured
Using Zod Schemas
SetstructuredOutput in AgentConfig:
How It Works
responseFormat
RadarOS converts the schema to the provider’s
responseFormat (e.g., { type: "json_schema", schema: {...} }).RunOutput.structured
WhenstructuredOutput is set, the parsed and validated result is available on RunOutput.structured:
Example: Sentiment Analysis Agent
Example: City Info with Rich Schema
Structured Output in Express / Swagger
When you expose an agent withstructuredOutput via Express, RadarOS automatically generates a typed response schema in the OpenAPI spec. Swagger UI will display the exact shape of the structured field — consumers of your API see the full contract without extra documentation.
POST /api/agents/analyst/run will include:
structuredOutput use the generic RunOutput schema where structured is untyped.
Provider Support
| Provider | Support |
|---|---|
| OpenAI | responseFormat: { type: "json_schema", schema: {...} } |
| Google Gemini | responseFormat: "json" with json_schema |
| Anthropic | Structured output via tool use or response format where supported |
| Vertex AI | responseFormat: "json" with json_schema |