Skip to main content

A lightweight, stateless multi-agent orchestration framework.

Project description

SwarmX (forked from OpenAI's Swarm)

PyPI version Python Version License: MIT Downloads GitHub stars GitHub forks GitHub issues Ruff

An extreme simple framework exploring ergonomic, lightweight multi-agent orchestration.

Highlights

  1. SwarmX is both Agent and Workflow
  2. MCP servers support
  3. OpenAI-compatible streaming-server
  4. Workflow import/export in JSON format

asciicast

Star History

Star History Chart

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 support
  • GET /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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmx-0.6.3a1.tar.gz (474.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmx-0.6.3a1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file swarmx-0.6.3a1.tar.gz.

File metadata

  • Download URL: swarmx-0.6.3a1.tar.gz
  • Upload date:
  • Size: 474.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for swarmx-0.6.3a1.tar.gz
Algorithm Hash digest
SHA256 303e52730d792ea20705e6f62ef9c9fc7d26223532ff42c74237c999b221a881
MD5 7a9d742232197b1fa1844f5ed3e60a95
BLAKE2b-256 64886fab3930edef37a42bd84f1c3cdad6bf1c0682992d1190e5fb6d77b5a306

See more details on using hashes here.

File details

Details for the file swarmx-0.6.3a1-py3-none-any.whl.

File metadata

  • Download URL: swarmx-0.6.3a1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for swarmx-0.6.3a1-py3-none-any.whl
Algorithm Hash digest
SHA256 5534011f318ae8a4f93f2659cb8836abd0a133f275d058c63577cb0dca56d6b5
MD5 fa65eed81959caf5aaa1719d0e119e0e
BLAKE2b-256 3241efc76ddd2d3e7b2d8743f08ef9f7cd24d956e0d3eb5ebb7ee777c5ee742a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page