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

Quick Start

1

JSON Output

import { Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'Extract contact information',
  outputFormat: 'json'
});

const result = await agent.chat('John Smith, [email protected], 555-1234');
// { name: "John Smith", email: "[email protected]", phone: "555-1234" }
2

With Schema

const agent = new Agent({
  instructions: 'Extract product info',
  outputSchema: {
    name: 'string',
    price: 'number',
    inStock: 'boolean'
  }
});

User Interaction Flow


Configuration Levels

// Level 1: String - Simple format
const agent = new Agent({
  outputFormat: 'json'  // or 'markdown', 'text'
});

// Level 2: Dict - Schema definition
const agent = new Agent({
  outputSchema: {
    title: 'string',
    points: 'string[]',
    score: 'number'
  }
});

// Level 3: Instance - Full control with Zod
import { z } from 'zod';

const agent = new Agent({
  outputSchema: z.object({
    title: z.string(),
    points: z.array(z.string()),
    score: z.number().min(0).max(100)
  })
});

Output Formats

FormatUse Case
jsonStructured data extraction
markdownFormatted documents
textPlain text response
SchemaCustom typed output

API Reference

OutputConfig

Output configuration options

Best Practices

Schemas ensure agents return predictable structures every time.
Start with basic types. Complex nested schemas may confuse some models.
Zod schemas provide runtime type checking for extra safety.