# OpenAI Swarm — Lightweight Multi-Agent Orchestration > Educational multi-agent framework by OpenAI. Ergonomic agent handoffs, tool calling, and context variables. Minimal abstraction over Chat Completions API. 21K+ stars. ## Install Save as a script file and run: ## Quick Use ```bash pip install git+https://github.com/openai/swarm.git ``` ```python from swarm import Swarm, Agent client = Swarm() def transfer_to_sales(): return sales_agent triage = Agent(name="Triage", instructions="Route to sales or support.", functions=[transfer_to_sales]) sales_agent = Agent(name="Sales", instructions="Handle sales inquiries.") response = client.run(agent=triage, messages=[{"role": "user", "content": "I want to buy your product"}]) print(response.messages[-1]["content"]) ``` --- ## Intro Swarm is an educational multi-agent orchestration framework by OpenAI. It explores lightweight, ergonomic patterns for agent handoffs, tool calling, and context variables — with minimal abstraction over the Chat Completions API. Designed to teach multi-agent patterns, not as a production framework. 21,000+ GitHub stars, MIT licensed. **Best for**: Learning multi-agent patterns, prototyping agent handoff workflows, understanding OpenAI's agent design philosophy **Works with**: OpenAI API (GPT-4o, GPT-4, GPT-3.5) --- ## Core Concepts ### Agents Agents are instructions + functions. Simple and composable: ```python agent = Agent( name="Support", instructions="You handle customer support.", functions=[lookup_order, check_status, escalate], ) ``` ### Handoffs Agents transfer control by returning another agent: ```python def transfer_to_billing(): return billing_agent # Control passes to billing ``` ### Context Variables Share state across agents without global variables: ```python response = client.run(agent=triage, messages=[...], context_variables={"user_id": "123", "plan": "premium"}) ``` ### Routines Multi-step procedures encoded as agent instructions — like a playbook for the agent to follow. --- ### FAQ **Q: What is OpenAI Swarm?** A: An educational framework by OpenAI exploring lightweight multi-agent orchestration with handoffs, tool calling, and context variables. 21K+ stars, MIT licensed. **Q: Should I use Swarm in production?** A: OpenAI explicitly states Swarm is educational, not a production framework. For production, consider OpenAI Agents SDK, LangGraph, or CrewAI. --- ## Source & Thanks > Created by [OpenAI](https://github.com/openai). Licensed under MIT. > [openai/swarm](https://github.com/openai/swarm) — 21,000+ GitHub stars --- Source: https://tokrepo.com/en/workflows/d75dad10-15d3-4530-9e8c-4558ec701a27 Author: Script Depot