import os
import requests
result = requests.post(
"https://api.swarms.world/v1/swarm/completions",
headers={"x-api-key": os.environ["SWARMS_API_KEY"], "Content-Type": "application/json"},
json={
"name": "Software Development GroupChat",
"description": "Collaborative group: coder, reviewer, and PM",
"swarm_type": "GroupChat",
"task": "Build a Python function that rates the readability of a text on a 1-10 scale.",
"agents": [
{
"agent_name": "Coder",
"system_prompt": "You are an expert software engineer. Write clean, efficient, well-documented code.",
"model_name": "gpt-4.1",
"max_loops": 1,
"temperature": 0.3,
},
{
"agent_name": "Code_Reviewer",
"system_prompt": "You are a senior code reviewer. Review code for bugs, edge cases, and best practices. Provide specific, actionable feedback.",
"model_name": "gpt-4.1",
"max_loops": 1,
"temperature": 0.2,
},
{
"agent_name": "Product_Manager",
"system_prompt": "You are a product manager. Ensure solutions meet business requirements, are maintainable, and deliver real user value.",
"model_name": "gpt-4.1",
"max_loops": 1,
"temperature": 0.3,
},
],
"max_loops": 5,
},
timeout=180,
).json()
print(result["outputs"])