A lightweight, stateless multi-agent orchestration framework.
Project description
SwarmX (forked from OpenAI's Swarm)
An extreme simple framework exploring ergonomic, lightweight multi-agent orchestration.
Highlights
- SwarmX is both Agent and Workflow
- MCP servers support
- OpenAI-compatible streaming-server
Star History
Quick start
After setting OPENAI_API_KEY environment variable, you can start a simple REPL by running the following command:
export OPENAI_API_KEY="your-api-key"
# export OPENAI_BASE_URL="http://localhost:11434/v1" # optional
uvx swarmx # Start interactive REPL
API Server
You can also start SwarmX as an OpenAI-compatible API server:
uvx swarmx serve --host 0.0.0.0 --port 8000
This provides OpenAI-compatible endpoints:
POST /v1/chat/completions- Chat completions with streaming supportGET /v1/models- List available models
Use it with any OpenAI-compatible client:
import openai
client = openai.OpenAI(
base_url="http://localhost:8000/v1",
api_key="dummy" # SwarmX doesn't require authentication
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
Installation
Requires Python 3.11+
$ pip install swarmx # or `uv tool install swarmx`
Usage
import asyncio
from swarmx import Swarm, Agent
client = Swarm()
def transfer_to_agent_b():
return agent_b
agent_a = Agent(
name="Agent A",
instructions="You are a helpful agent.",
functions=[transfer_to_agent_b],
)
agent_b = Agent(
name="Agent B",
model="deepseek-r1:7b",
instructions="你只能说中文。", # You can only speak Chinese.
)
async def main():
response = await client.run(
agent=agent_a,
messages=[{"role": "user", "content": "I want to talk to agent B."}],
)
print(response.messages[-1]["content"])
asyncio.run(main())
Architecture
graph TD
classDef QA fill:#ffffff;
classDef agent fill:#ffd8ac;
classDef tool fill:#d3ecee;
classDef result fill:#b4f2be;
func1("transfer_to_weather_assistant()"):::tool
Weather["Weather Assistant"]:::agent
func2("get_weather('New York')"):::tool
temp(64):::result
A["It's 64 degrees in New York."]:::QA
Q["What's the weather in ny?"]:::QA -->
Triage["Triage Agent"]:::agent --> Weather --> A
Triage --> func1 --> Weather
Weather --> func2 --> temp --> A
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmx-0.6.3a0.tar.gz.
File metadata
- Download URL: swarmx-0.6.3a0.tar.gz
- Upload date:
- Size: 473.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f881e5fde5a184fc668ca84aeec844758aee553bfbb75ad3f59f41e5794b03c0
|
|
| MD5 |
6d05222319ab9b0e539fe0a853b1faa3
|
|
| BLAKE2b-256 |
3e88cae764c830092d8bb1d4e54cc6efaed3c223a969bdbf461f1bb7285e3cc2
|
File details
Details for the file swarmx-0.6.3a0-py3-none-any.whl.
File metadata
- Download URL: swarmx-0.6.3a0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a5f5372d92cfea48fc5a51d530559ae1921210634cc8d8b20f1b2b09b0372e0
|
|
| MD5 |
4a3d98b64a7cb23b4a61811613e880aa
|
|
| BLAKE2b-256 |
db68d8b5446862e0427325d3882dfab92478bf56068b0804e9512e31af0e95fa
|