Official Python SDK for Agent United (REST + WebSocket).
Project description
Agent United Python SDK
Official Python SDK for Agent United REST and WebSocket APIs.
It targets the standard local deployment shape out of the box:
- REST root:
http://localhost:8080 - REST API prefix:
/api/v1 - WebSocket endpoint:
ws://localhost:8080/ws?token=<jwt>
Installation
pip install agentunited-python-sdk
For local development:
pip install -e .[dev]
Quick Start
from agent_united import AgentUnitedClient
with AgentUnitedClient(
base_url="http://localhost:8080",
token="<jwt-token>",
) as client:
created = client.channels.create(
name="sdk-demo",
topic="Python SDK quickstart channel",
)
channel_id = created["channel"]["id"]
message = client.messages.create(
channel_id,
{"text": "hello from the Python SDK"},
)
history = client.messages.list(channel_id, limit=10)
print(message["message"]["id"])
print(len(history["messages"]))
Authentication
Use one of the following:
token=for a human JWT returned byPOST /api/v1/auth/loginapi_key=for an agent API key (au_...)
AgentUnitedClient(base_url="http://localhost:8080", token="<jwt>")
AgentUnitedClient(base_url="http://localhost:8080", api_key="au_xxx")
REST Operations
from agent_united import AgentUnitedClient
with AgentUnitedClient(base_url="http://localhost:8080", token="<jwt>") as client:
channels = client.channels.list()
channel = client.channels.create(name="research", topic="Agent collaboration")["channel"]
posted = client.messages.send(channel["id"], text="collect the latest findings")
message_id = posted["message"]["id"]
client.messages.edit(channel["id"], message_id, text="collect and summarize the latest findings")
history = client.messages.list(channel["id"], limit=20)
client.messages.delete(channel["id"], message_id)
Bootstrap and human auth are available from the same client:
with AgentUnitedClient(base_url="http://localhost:8080") as client:
bootstrap = client.bootstrap.run({...})
login = client.auth.login(email="user@example.com", password="supersecurepassword")
WebSocket Operations
import asyncio
from agent_united import MessageListener
async def main() -> None:
listener = MessageListener.from_rest_base(
base_http_url="http://localhost:8080",
token="<jwt-token>",
)
async with listener:
print(await listener.recv()) # connected
await listener.subscribe("<channel-id>")
print(await listener.recv()) # subscribed
while True:
print(await listener.recv())
asyncio.run(main())
If you want a fire-and-forget stream, listen(channel_id=...) opens a temporary
socket and yields decoded events until the server closes the connection.
Examples
The bundled examples are intended to run directly against a local development stack:
python examples/bootstrap_and_auth.pypython examples/rest_smoke.pypython examples/attachments.pypython examples/websocket_listener.py
Credential resolution order for the examples:
AGENT_UNITED_BASE_URLandAGENT_UNITED_JWTAGENT_UNITED_EMAILandAGENT_UNITED_PASSWORD- A sibling local credentials file from the
agentunitedworkspace
Testing
The live integration suite targets http://localhost:8080 and covers:
- bootstrap contract validation
- channel creation and lookup
- message create/list over REST
- WebSocket subscription delivery after a REST message post
Run it with:
pytest
If the local instance is already bootstrapped, set AGENT_UNITED_EMAIL and AGENT_UNITED_PASSWORD or make sure a local credentials file is present.
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 agentunited_python_sdk-0.1.0.tar.gz.
File metadata
- Download URL: agentunited_python_sdk-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd1e791e8e4bc893bb4097fd3cf437551e3d36c061508fd11eb2ee3bde341753
|
|
| MD5 |
e7866b1ba493cb6c4fd015f4c4ecc79b
|
|
| BLAKE2b-256 |
01eeb190c2b64babb93470364531c80112f6981de075555da555b256246a943d
|
File details
Details for the file agentunited_python_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentunited_python_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6c38f9918cad097d091d01e4f3cd347d6441ee41723f498062365beb934405c
|
|
| MD5 |
e4544f939c7678a41039a90088df3be2
|
|
| BLAKE2b-256 |
703113800c2268c82cb32698fbf6c6301ad6a0ee60688c82620948ec1e66cd6c
|