Create Custom Recipes

Step-by-step guide to creating your own PraisonAI recipes

Define roles and tasks in agents.yaml, then run the recipe from the CLI.

python
from praisonaiagents import Agent

agent = Agent(
    name="Recipe Author",
    instructions="Design multi-step recipe roles and validate outputs.",
)
agent.start("Outline a two-agent research recipe.")

The user authors agents.yaml, runs praisonai recipe run, and receives output from each role.

Diagram

Create Recipe

📋 agents.yaml

⚙️ Validate & Run

✅ Role Output

How It Works

Diagram
RecipeCLIUserRecipeCLIUserpraisonai recipe init + edit agents.yamlValidate schemaRoles and tasks resolvedOutput from each role

How to Create a Custom Recipe from Scratch

  1. Create Recipe Directory

    Create a new directory for your recipe with the required structure:

    bash
    mkdir -p my-recipe
    cd my-recipe
  2. Create agents.yaml

    Create the main recipe configuration file:

    yaml
    # agents.yaml
    framework: praisonai
    topic: "{{task}}"
    
    roles:
      researcher:
        role: Research Specialist
        goal: Research the given topic thoroughly
        backstory: Expert researcher with attention to detail
        tools:
          - internet_search
        tasks:
          research_task:
            description: |
              Research: {{task}}
              Provide comprehensive findings.
            expected_output: "Detailed research report"
  3. Test Your Recipe Locally

    Run your recipe to verify it works:

    bash
    praisonai recipe run ./my-recipe --var task="AI trends 2024"

How to Create a Recipe with CLI

  1. Initialize Recipe
    bash
    praisonai recipe init my-new-recipe
  2. Edit Generated Files
    bash
    cd my-new-recipe
    # Edit agents.yaml as needed
  3. Validate Recipe
    bash
    praisonai recipe validate ./my-new-recipe
  4. Run Recipe
    bash
    praisonai recipe run my-new-recipe --var task="Your task here"

Recipe File Structure

my-recipe/
├── agents.yaml        # Agent definitions and tasks
├── tools.py           # Optional: custom tools
└── README.md          # Optional: documentation

agents.yaml Schema

FieldTypeRequiredDescription
frameworkstringYesShould be praisonai
topicstringYesMain topic/task
rolesobjectYesAgent definitions
roles.*.rolestringYesAgent role name
roles.*.goalstringYesAgent goal
roles.*.toolsarrayNoTools for agent
roles.*.tasksobjectYesAgent tasks

Best Practices

Start from praisonai recipe init

The scaffold gives you a valid agents.yaml to edit, so you avoid schema mistakes on the first pass.

Give each role a clear goal and expected_output

Specific goals and expected_output fields keep multi-role recipes on track and make outputs predictable.

Validate before running

Run praisonai recipe validate ./my-recipe after each change so schema errors surface before execution.


Related