Skip to main content
AI21 Maestro is an intelligent agentic system designed to handle complex AI workflows.
This guide focuses specifically on the Validated Output, providing practical examples that range from basic usage to advanced scenarios.

Understanding the Problem

Traditional LLM interactions often look like this:
Python
Common issues:
  • LLMs often fail to consistently meet all the individual requirements outlined in the promp
  • There is no visibility into which requirements were not met
  • Requires manual trial and error to achieve the desired output

How AI21 Maestro Works

Maestro’s instruction following enhancer uses a Generate → Validate → Fix cycle:
  1. Generate: Creates initial response following your requirements
  2. Validate: Evaluates and scores each requirement (0.0 to 1.0)
  3. Fix: Refines output for requirements that scored < 1.0
  4. Repeat: Continues until all requirements are met or budget is exhausted
This systematic approach to instruction following is part of Maestro’s broader agentic architecture, designed to handle complex workflows with reliability and precision.
text

Using the API

The Input parameter You can pass a string to Maestro as an input and it will be treated as a user message.
Python
Alternatively you can pass an input as an array of message to support multiple turns in a conversation.
Python

System Prompt

The system_prompt defines the agent’s identity, operating principles, and boundaries before it processes any input.
It guides how Maestro interprets inputs, chooses tools, and reasons throughout the run.
Use it to:
  • Define the agent’s role and identity
    Example: “You are a cautious financial journalist. Verify all data before reporting”
  • Provide context or environment
    Example: Today’s date is November 10, 2025. User location: New York.
  • Define behavioral rules
    Example: “Always verify numbers from reliable sources before reporting. If data is unclear, ask a clarifying question.”

Working with Requirements

Writing Effective Requirements

Good Requirements:
Python
Requirements to Avoid:
Python

Requirement Categories

Format Requirements:
Python
Content Requirements:
Python
Style Requirements:
Python
Technical Requirements:
Python

Requirements Report

Enable detailed reporting by including requirements_result:
Python
Sample Output Analysis
Python
This tells you:
  • 2 out of 3 requirements were perfectly met
  • The rating requirement needs refinement
  • You might need a higher budget or clearer requirement

Budget Control and Performance

Use the budget parameter to control how much computational effort AI21 Maestro applies when executing your task. Higher budgets improve reasoning reliability but increase latency and cost.  
The snippet below shows how to set different budget levels in your Maestro run. Replace task and requirements with your own input values and make sure the client is initialized with your API key as shown in the Quickstar.
Budget Levels Explained
Python

Using Third-Party Models

You can run Maestro tasks with both AI21 and third-party models.
Use the models parameter to specify which model to run your task with.
If no model is specified, Maestro will automatically select a suitable model based on the task requirements.
Python

Setting the Response Language

You can control the output language of Maestro’s response using the response_language parameter. For example, to receive the result in Spanish: