import os
from swarms_client import SwarmsClient
client = SwarmsClient(api_key=os.environ["SWARMS_API_KEY"])
# A MultiAgentRouter: the router reads the ticket and picks one specialist.
# Each specialist runs on the model that suits its work and returns a draft
# for the line lead or engineer to approve.
ticket = (
"Ticket 4471, Line 2, Station 3 (paint booth), 14:20. Operator reports "
"orange peel on 14 consecutive door panels, lot DP-2291. Booth humidity "
"reading 71 percent against a 55 to 65 percent spec. Units moved to the hold rack."
)
response = client.swarms.run(
name="Line 2 Ticket Desk",
description="Route shop-floor tickets to the quality, maintenance or supply specialist.",
swarm_type="MultiAgentRouter",
task=ticket,
agents=[
{
"agent_name": "Quality Engineer",
"description": "Defects, nonconformances, holds and dispositions.",
"system_prompt": (
"You are a quality engineer on an automotive paint and assembly line. "
"For a defect ticket, state the likely cause from the evidence given, "
"the containment (what to hold, what to inspect), and a draft disposition "
"(use as is, rework, scrap) marked FOR QUALITY MANAGER APPROVAL."
),
"model_name": "claude-sonnet-5-5", # careful reasoning on dispositions
"max_loops": 1,
},
{
"agent_name": "Maintenance Planner",
"description": "Equipment faults, sensor flags and work orders.",
"system_prompt": (
"You are a maintenance planner. For an equipment ticket, draft a work "
"order: asset, symptom, probable failure mode, parts likely needed, "
"priority P1 to P3 with the reason, and the shift window you suggest."
),
"model_name": "gpt-5.4",
"max_loops": 1,
},
{
"agent_name": "Supply Analyst",
"description": "Late lots, shortages and supplier notices.",
"system_prompt": (
"You are a supply chain analyst. For a material ticket, state days of "
"cover from the inventory figures given, the options (expedite, "
"alternate supplier, reschedule) and draft the note to the supplier."
),
"model_name": "gemini-2.5-flash", # fast, cheap for volume tickets
"max_loops": 1,
},
],
max_loops=1,
)
print(response)