Translation: CrewAI Flows → Lyzr ADK
Source: https://github.com/crewAIInc/crewAI-examples/tree/main/flows/write_a_book_with_flows
Generated by: Framework Translator Agent v2.0.0
An AI book-writer pipeline that:
- Researches a topic and generates a structured chapter outline
- Writes all chapters in parallel (~3 000 words each, Markdown)
- Joins and saves the complete book to a
.mdfile on disk
The original CrewAI code used two Crews orchestrated by a Flow; this translation
uses four Lyzr ADK agents orchestrated by a plain Python async function that
preserves identical parallel chapter-writing behaviour.
| Lyzr Agent | Source CrewAI Agent | Crew |
|---|---|---|
outline_researcher |
researcher |
OutlineCrew |
book_outliner |
outliner |
OutlineCrew |
chapter_researcher |
researcher |
WriteBookChapterCrew |
chapter_writer |
writer |
WriteBookChapterCrew |
pip install lyzr-adk requests pydanticexport LYZR_API_KEY="sk-..." # from https://studio.lyzr.ai → Settings → API Keys
export OPENAI_API_KEY="sk-..." # required by openai/gpt-4o inside Lyzr
export SERPER_API_KEY="..." # from https://serper.dev — used by web_search toolpython3 write_a_book_lyzr_adk.pyThe script will:
- Create 4 agents in your Lyzr Studio workspace (one-time)
- Run the book generation flow
- Save the finished book as
The_Current_State_of_AI_in_July_2025.mdin the current directory
| # | Source (CrewAI) | Target (Lyzr ADK) | Fidelity |
|---|---|---|---|
| 1 | Flow[BookState] with @start/@listen |
Plain async Python orchestration function |
Adapted |
| 2 | crewai_tools.SerperDevTool |
web_search() function calling Serper.dev REST API |
Adapted |
| 3 | output_pydantic=BookOutline / output_pydantic=Chapter (CrewAI task) |
response_model=BookOutline / response_model=Chapter (Lyzr agent.run()) |
Direct |
| 4 | @persist durable Flow state |
Not supported — crash = restart from Stage 1 | Lossy |
| 5 | asyncio.gather() parallel chapters |
asyncio.gather() preserved identically |
Direct |
| 6 | Process.sequential inside each Crew |
Sequential agent.run() calls within each stage |
Direct |
| 7 | crew.kickoff(inputs={...}) |
agent.run(prompt) |
Adapted |
| 8 | YAML agents.yaml / tasks.yaml configs |
Inline studio.create_agent(role=, goal=, instructions=) |
Adapted |
[main()]
│
▼
[create_all_agents()] ← POST /v3/agents/ × 4 (runs once at startup)
│
▼
[generate_book_outline()] ← Stage 1 (sequential)
│ outline_researcher.run() → research findings
│ book_outliner.run() → BookOutline (JSON → Pydantic)
│
▼
[write_chapters()] ← Stage 2 (parallel via asyncio.gather)
│ for each ChapterOutline:
│ chapter_researcher.run() → research findings
│ chapter_writer.run() → Chapter (Markdown)
│
▼
[join_and_save_chapter()] ← Stage 3 (sequential)
Combine all chapters → write ./{Book_Title}.md
| File | Description |
|---|---|
write_a_book_lyzr_adk.py |
Main translated script — run this |
README.md |
This file |