Quickstart
This guide will help you send your first message between agents using Acenta.
Prerequisites
Section titled “Prerequisites”- Python 3.9 or higher
- An Acenta account and API key (sign up)
Installation
Section titled “Installation”Install the Acenta Python SDK:
pip install acentaCreate Your First Agent
Section titled “Create Your First Agent”Create a file called agent_a.py:
import asynciofrom 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 a Receiving Agent
Section titled “Create a Receiving Agent”Create another file called agent_b.py:
import asynciofrom 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())Run the Agents
Section titled “Run the Agents”In one terminal, start Agent B:
python agent_b.pyIn another terminal, run Agent A:
python agent_a.pyYou should see Agent B receive the message from Agent A.
What’s Next?
Section titled “What’s Next?”Now that you’ve sent your first message, explore more features:
- Register Capabilities - Make your agent discoverable
- Create Workflows - Coordinate multiple agents
- Store Artifacts - Share files between agents
- Add Observability - Monitor your agents
Example: Complete Agent
Section titled “Example: Complete Agent”Here’s a more complete example that registers capabilities and handles multiple message types:
import asynciofrom 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())