DocsOrchestrating multiple agents

Orchestrating multiple agents

Use casesAdvanced30 min

You'll build a script where a strong model makes a plan, cheap models do the parts in parallel, and an editor merges everything into a report, all on one key.

You need: a fetch_... key (create one), a balance (one report costs about a cent), Python 3.10+.

  1. 1
    Pick the models

    Planner and editor: claude-sonnet-5-5 or claude-sonnet-5; for the hardest tasks give the planner claude-opus-5-5. Workers: deepseek-v4.1-flash or claude-haiku-5-5.

  2. 2
    Save the code

    Copy the code below into a file named research.py.

  3. 3
    Run it
    bash
    pip install openai
    export ZUKKO_API_KEY="fetch_your_key"
    python research.py "The e-scooter market in Europe in 2026"

    The report is printed and saved to report.md; the step log goes to the console.

  4. 4
    Read the log

    It shows the cost and time of each step. Workers write poorly: give them claude-haiku-5-5. Report is shallow: use a stronger planner.

1Code

research.py
"""
A team of agents: planner -> workers in parallel -> editor.
pip install openai
python research.py "The e-scooter market in Europe in 2026"
"""
import asyncio
import json
import os
import sys
import time
import urllib.request

from openai import AsyncOpenAI

The code reads the cost of each request from the X-Zukko-Cost-Micros header. Before every request it checks the total against BUDGET_USD and stops when the cap is reached.

2Ready-made frameworks

Set base_url and your Zukko key. Exact parameter names depend on the library version.

LibrarySetup
OpenAI Agents SDKset_default_openai_client(AsyncOpenAI(base_url="https://api.zukko.pro/v1", api_key=...)) and set_default_openai_api("chat_completions")
LangGraph (via LangChain)ChatOpenAI(model="claude-sonnet-5", base_url="https://api.zukko.pro/v1", api_key=...)
CrewAILLM(model="openai/claude-sonnet-5", base_url="https://api.zukko.pro/v1", api_key=...)
AutoGenOpenAIChatCompletionClient(model="claude-sonnet-5", base_url="https://api.zukko.pro/v1", api_key=..., model_info={...}); for non-OpenAI models describe their capabilities in model_info

3If it doesn't work

What you seeWhat to do
"the planner returned an unusable plan"Tighten the format in PLANNER_SYSTEM or use a stronger model
APITimeoutErrorRaise timeout to 300 seconds
"budget used up"Find the expensive step in the log; raise BUDGET_USD or trim the context
429 key_daily_limit_reachedMake sure nothing is looping, then raise the key limit
402Top up; retrying won't help
Made-up numbers in the reportKeep USE_WEB_SEARCH = True and the requirement to cite sources

Other errors: API errors.

Orchestrating multiple agents · Zukko Docs