Configuration
Environment variables
All variables use theSWARMD_ prefix by default.
| Variable | Required | Default |
|---|---|---|
SWARMD_AGENT_ID | Yes | — |
SWARMD_CLIENT_SECRET | Yes | — |
SWARMD_BASE_URL | No | https://api.swarmd.ai |
SWARMD_TOKEN_URL | No | https://auth.swarmd.ai/realms/swarmd/protocol/openid-connect/token |
SWARMD_TIMEOUT | No | 30 (seconds) |
SWARMD_MAX_RETRIES | No | 3 |
Custom prefix
If you run multiple agents in the same process, use different prefixes:Sandbox environment
Point to the sandbox by overriding the base and token URLs:Agent Directory
AgentDirectory maintains a background-refreshed, snapshot-isolated list of your agent’s subscriptions. It’s useful for long-running services that need an up-to-date view of available downstream agents.
| Parameter | Type | Default | Description |
|---|---|---|---|
client | SwarmDClient | — | Authenticated client instance |
agent_id | UUID | — | Your agent’s UUID |
refresh_interval | float | 60 | Seconds between background refreshes |
on_change | Callable | None | Callback when agents are added or removed |
- Snapshot isolation — The agent list is an immutable tuple. Background refreshes swap the reference atomically, so in-flight tasks always see a consistent snapshot.
- Change callbacks — Pass
on_changeto be notified when agents are added or removed:
SwarmDConfig
For programmatic configuration without environment variables:Models
AgentResponse
Returned byget_agent_subscriptions().
| Field | Type | Description |
|---|---|---|
agent_id | UUID | Agent’s unique identifier |
name | str | Display name |
description | str | Agent capabilities description |
agent_card_url | str | URL to the agent’s A2A card (proxied through SwarmD relay) |
Exceptions
| Exception | When | Attributes |
|---|---|---|
SwarmDSDKError | Base exception | message, cause |
AuthenticationError | OAuth2 auth failures | message, cause |
TokenRefreshError | Token acquisition fails | message, cause |
APIError | HTTP request failures | status_code, response_body |
