Skip to main content
SPADE-LLM Logo

SPADE-LLM: Large Language Model Integration for Multi-Agent Systems

SPADE-LLM is a Python framework that extends SPADE multi-agent platform with Large Language Model capabilities. Build AI agents powered by OpenAI GPT, Ollama, LM Studio, and other LLM providers for multi-agent systems, with communication via XMPP for distributed AI applications.

Keywords: SPADE, LLM, large language models, multi-agent systems, AI agents, OpenAI, GPT, Ollama, chatbot framework, distributed AI, Python AI, agent communication, XMPP agents, AI collaboration

Table of Contents

Key Features

  • Built-in XMPP Server - No external server setup needed! Start agents with one command
  • Multi-LLM Provider Support - Integrate OpenAI models, Ollama local models, LM Studio and more via LiteLLM
  • RAG System - Retrieval-Augmented Generation with document loading, text splitting, and vector store retrieval (ChromaDB)
  • Structured Outputs - Type-safe LLM responses using Pydantic models; define the schema, get back structured data
  • Coordinator Agents - LLM-driven orchestration of SPADE subagents with shared context and automatic routing
  • Advanced Tool System - Function calling, async execution, LangChain tool integration, custom tool development
  • Smart Context Management - Multi-conversation support, automatic cleanup, sliding window, token-aware context
  • Persistent Memory - Agent-based memory, conversation threading, long-term state persistence across sessions
  • Intelligent Message Routing - Conditional routing based on LLM responses, dynamic agent selection
  • Content Safety Guardrails - Input/output filtering, keyword blocking, content moderation, safety controls
  • MCP Integration - Model Context Protocol server support for external tools and services
  • Human-in-the-Loop - Web interface for human expert consultation, interactive decision making

Installation instructions

Requirements

  • Python 3.11+
  • (recommended) uv installation for environment management

Install

# Install with uv (recommended)
uv pip install spade_llm

# Or install with pip
pip install spade_llm

# If working on a project with uv
uv add spade_llm

For optional features:

# RAG support with ChromaDB
pip install spade_llm[chroma]   # or: uv add spade_llm --extra chroma

# LangChain tool integration
pip install spade_llm[langchain]   # or: uv add spade_llm --extra langchain

Built-in XMPP Server

SPADE 4+ includes a built-in XMPP server, eliminating the need for external server setup. This is a major advantage over other multi-agent frameworks like AutoGen or Swarm that require complex infrastructure configuration.

Start the Server

# Start SPADE's built-in XMPP server
spade run

The server automatically handles:

  • Agent registration and authentication
  • Message routing between agents
  • Connection management
  • Domain resolution

Agents automatically connect to the built-in server when using standard SPADE agent configuration.

Quick Start

Get started with SPADE-LLM in just 2 steps:

Step 1: Start the Built-in XMPP Server

# Terminal 1: Start SPADE's built-in server
spade run

Step 2: Create and Run Your LLM Agent

# your_agent.py
import spade
from spade_llm import LLMAgent, LLMProvider

async def main():
    provider = LLMProvider(
        model="gpt-5-nano",
        api_key="your-api-key",
    )

    agent = LLMAgent(
        jid="assistant@localhost",  # Connects to built-in server
        password="password",
        provider=provider,
        system_prompt="You are a helpful assistant"
    )

    await agent.start()

if __name__ == "__main__":
    spade.run(main())
# Terminal 2: Run your agent
python your_agent.py

Examples

Multi-Provider Support

# OpenAI
provider = LLMProvider(model="gpt-5-nano", api_key="key")

# Ollama (local)
provider = LLMProvider(model="ollama/llama3.1:8b")

# Any OpenAI-compatible API (LM Studio, vLLM, etc.)
provider = LLMProvider(model="openai/local-model", base_url="http://localhost:1234/v1")

Tools and Function Calling

from spade_llm import LLMTool

async def get_weather(city: str) -> str:
    return f"Weather in {city}: 22°C, sunny"

weather_tool = LLMTool(
    name="get_weather",
    description="Get weather for a city",
    parameters={
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"]
    },
    func=get_weather
)

agent = LLMAgent(
    jid="assistant@localhost",  # Uses built-in server
    password="password",
    provider=provider,
    tools=[weather_tool]
)

Structured Outputs

from pydantic import BaseModel
from spade_llm import LLMAgent, LLMProvider

class WeatherReport(BaseModel):
    city: str
    temperature: float
    conditions: str

provider = LLMProvider(model="gpt-5-nano", api_key="key")
agent = LLMAgent(
    jid="weather@localhost",
    password="password",
    provider=provider,
    system_prompt="Extract weather information",
    output_schema=WeatherReport,
)

RAG (Retrieval-Augmented Generation)

from spade_llm import RetrievalAgent, LLMProvider
from spade_llm.rag import DirectoryLoader, RecursiveCharacterTextSplitter, ChromaVectorStore, VectorStoreRetriever

# Load, split, and index documents
loader = DirectoryLoader("./docs")
splitter = RecursiveCharacterTextSplitter(chunk_size=500)
docs = splitter.split_documents(loader.load())
store = ChromaVectorStore(collection_name="my_docs")
await store.add_documents(docs)

retriever = VectorStoreRetriever(vector_store=store)
agent = RetrievalAgent(
    jid="rag@localhost",
    password="password",
    provider=LLMProvider(model="gpt-5-nano", api_key="key"),
    retriever=retriever,
)

Documentation

Contributing

See Contributing Guide.

License

MIT License

Metadata

Release files for spade-llm 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spade-llm 0.3.0
File Size Uploaded
spade_llm-0.3.0.tar.gz 82.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spade-llm 0.3.0
File Interpreter ABI Platform
spade_llm-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 199.3 kB

Release files / spade_llm-0.3.0.tar.gz

Download URL spade_llm-0.3.0.tar.gz
Size 82.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e4eea08b183209f22b5225a01cefe299200ca9bb86c9dcaae68ebe51d0cf00bb
BLAKE2b-256 checksum
How to use checksums
a402936e2e995e9d4c5a26634994b84a0a1ab96afe9e511b6f3df459320ad99e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Release files / spade_llm-0.3.0-py3-none-any.whl

Download URL spade_llm-0.3.0-py3-none-any.whl
Size 117.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9376427b435bc195beb738f95d11d99487dc1b1c7c667eab1790da93265d509
BLAKE2b-256 checksum
How to use checksums
762b2d9ce4a87f7b3eb74635a99c5d6213c2cce049227c661435d8f629f86d5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page