Skip to main content
Tasks support various response formats to structure the output according to your needs. You can specify the expected format using the response_format parameter.

String Response (Default)

Pydantic Model Response

Complex Nested Models

Response Format Types

Best Practices

  • Structured Data: Use Pydantic models for complex, structured responses
  • Field Validation: Leverage Pydantic’s built-in validation for data integrity
  • Optional Fields: Use Optional types for fields that might not always be present
  • Nested Models: Break down complex responses into smaller, reusable models
  • Type Hints: Always provide clear type hints for better IDE support and validation
  • Default Values: Set appropriate default values for optional fields