import os
import requests
result = requests.post(
"https://api.swarms.world/v1/swarms/completions",
headers={"x-api-key": os.environ["SWARMS_API_KEY"], "Content-Type": "application/json"},
json={
"name": "Financial Report Crew",
"description": "Hierarchical crew for financial analysis and report writing",
"swarm_type": "HierarchicalSwarm",
"task": "Analyze Q4 2024 earnings data, extract key KPIs, and write a 300-word executive summary.",
"agents": [
{
"agent_name": "Data Analyst",
"system_prompt": (
"You are an expert Data Analyst specializing in financial modeling. "
"Analyze the provided financial data and extract key performance indicators, "
"growth metrics, and trends. Return a structured KPI report."
),
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.2,
},
{
"agent_name": "Report Writer",
"system_prompt": (
"You are a specialist Report Writer who translates complex financial data into "
"clear, readable reports. Using the analysis provided, write a 300-word "
"executive summary suitable for C-suite readers."
),
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.4,
},
],
"max_loops": 1,
},
timeout=120,
).json()
print(result["outputs"])