Skip to main content
Agents can return structured data in specific formats - JSON, lists, or custom schemas.

Quick Start

1

Simple Usage

2

With Configuration

outputSchema takes a JSON Schema object. See Structured Output for the full API.

User Interaction Flow


Schema-Constrained Output

Pass a JSON Schema object to outputSchema and the agent returns a JSON string that matches it.
As of v1.7.4, outputSchema is wired through OpenAI’s response_format: json_schema. The agent sends your schema to the model and returns a JSON string that matches it. Use outputSchemaName to name the schema in the request payload (default: "response").
outputSchema takes a JSON Schema object (Record<string, any>). Pass a full JSON Schema for reliable structured output.
agent.chat() returns the raw JSON string — parse it with JSON.parse(result).

Schema-constrained output (outputSchema)

outputSchema takes a JSON Schema object. When set, the agent sends it to OpenAI as response_format: { type: 'json_schema', json_schema: { name, schema } }, so the model is constrained to return matching JSON — the TypeScript parity of Python’s output_json / output_pydantic.
outputSchemaName names the schema in the response_format payload (default "response").
outputSchema works on every provider. OpenAI uses native response_format: json_schema; other providers (Anthropic, Google, Groq, Mistral, Ollama, …) go through the AI SDK backend’s generateObject({ schema }). Cross-provider parity landed in PraisonAI PR #4412.
Reasoning models omit temperature. gpt-5*, o1*, o3*, and o4* reject a non-default temperature with a 400. The client omits the parameter for these families (the default model is gpt-5-nano), so structured output works out of the box — set a temperature explicitly only for non-reasoning models.

Output Formats


API Reference

OutputConfig

Output configuration options

Best Practices

A JSON Schema ensures the agent returns the same structure every time.
Start with basic types. Deeply nested schemas can confuse some models.
List the fields you always expect in required so they aren’t dropped.
Set outputSchemaName to label the schema in OpenAI’s response_format payload. Defaults to "response".
outputSchema returns matching JSON on every supported provider. Switching the llm string from openai/... to anthropic/... or google/... does not change your schema code — see Structured Output → Provider support.

Agent

Create agents

Criteria

Validation rules