Skip to content

Quickstart

This guide will help you send your first message between agents using Acenta.

  • Python 3.9 or higher
  • An Acenta account and API key (sign up)

Install the Acenta Python SDK:

Terminal window
pip install acenta

Create a file called agent_a.py:

import asyncio
from acenta import AcentaClient
async def main():
# Initialize the client with your API key
client = AcentaClient(api_key="your-api-key")
# Send a message to Agent B
response = await client.messaging.send(
destination="agent-b",
event_name="greeting",
payload={"message": "Hello from Agent A!"}
)
print(f"Message sent! ID: {response.message_id}")
if __name__ == "__main__":
asyncio.run(main())

Create another file called agent_b.py:

import asyncio
from acenta import AcentaClient
async def main():
client = AcentaClient(api_key="your-api-key")
# Subscribe to messages
async for message in client.messaging.subscribe(agent_id="agent-b"):
print(f"Received: {message.payload}")
# Acknowledge the message
await client.messaging.acknowledge(message.message_id)
if __name__ == "__main__":
asyncio.run(main())

In one terminal, start Agent B:

Terminal window
python agent_b.py

In another terminal, run Agent A:

Terminal window
python agent_a.py

You should see Agent B receive the message from Agent A.

Now that you’ve sent your first message, explore more features:

Here’s a more complete example that registers capabilities and handles multiple message types:

import asyncio
from acenta import AcentaClient
async def main():
client = AcentaClient(api_key="your-api-key")
# Register this agent's capabilities
await client.discovery.register_capability(
agent_id="document-processor",
capability="document.ocr",
metadata={
"supported_formats": ["pdf", "png", "jpg"],
"max_file_size_mb": 50
}
)
print("Agent registered! Listening for messages...")
# Handle incoming messages
async for message in client.messaging.subscribe(agent_id="document-processor"):
if message.event_name == "process_document":
doc_id = message.payload.get("document_id")
print(f"Processing document: {doc_id}")
# Simulate processing
await asyncio.sleep(1)
# Send result back
await client.messaging.send(
destination=message.source,
event_name="document_processed",
payload={
"document_id": doc_id,
"status": "completed",
"extracted_text": "Sample extracted text..."
}
)
await client.messaging.acknowledge(message.message_id)
if __name__ == "__main__":
asyncio.run(main())