Skip to main content
Workflows support multiple input types for maximum flexibility:
When this input is passed to an Agent or Team, it will be serialized to a string before being passed to the agent or team.
See more on Pydantic as input in the Advanced Workflows documentation.

Structured Inputs with Pydantic

Leverage Pydantic models for type-safe, validated workflow inputs:

Validating the input

You can set input_schema on the Workflow to validate the input. If you then pass the input as a dictionary, it will be automatically validated against the schema.

Developer Resources

Structured Input/Output at Step Level

Workflows feature a powerful type-safe data flow system enabling each step to:
  1. Receive structured input (Pydantic models, lists, dicts, or raw strings)
  2. Produce structured output (validated Pydantic models)
  3. Maintain type safety throughout entire workflow execution

Data Flow Between Steps

Input Processing
  • First step receives the workflow’s input message
  • Subsequent steps receive the previous step’s structured output
Output Generation
  • Each Agent processes input using its configured output_schema
  • Output is automatically validated against the defined model

Structured Data Transformation in Custom Functions

Custom functions can access structured output from previous steps via step_input.previous_step_content, preserving original Pydantic model types. Transformation Pattern
  • Type-Check Inputs: Use isinstance(step_input.previous_step_content, ModelName) to verify input structure
  • Modify Data: Extract fields, process them, and construct new Pydantic models
  • Return Typed Output: Wrap the new model in StepOutput(content=new_model) for type safety
Example Implementation

Developer Resources

Media Input and Processing

Workflows seamlessly handle media artifacts (images, videos, audio) throughout the execution pipeline, enabling rich multimedia processing workflows. Media Flow System
  • Input Support: Media can be provided to Workflow.run() and Workflow.print_response()
  • Step Propagation: Media is passed through to individual steps (Agents, Teams, or Custom Functions)
  • Artifact Accumulation: Each step receives shared media from previous steps and can produce additional outputs
  • Format Compatibility: Automatic conversion between artifact formats ensures seamless integration
  • Complete Preservation: Final WorkflowRunOutput contains all accumulated media from the entire execution chain
Here’s an example of how to pass image as input:
If you are using Workflow.run(), you need to use WorkflowRunOutput to access the images, videos, and audio.
Similarly, you can pass Video and Audio as input.

Developer Resources