packages/examples/a2a/README.md
This directory contains A2A (Agent-to-Agent) server implementations that expose an elizaOS agent as an HTTP server. This enables agent-to-agent communication, webhooks, and integration with other AI systems.
Uses real elizaOS runtime.
OPENAI_API_KEY is set, the server will use an OpenAI-backed model (and SQL where supported).OPENAI_API_KEY is not set, the server runs in a deterministic “ELIZA classic” mode (no API keys required), backed by @elizaos/plugin-inmemorydb for ephemeral multi-turn state.| Framework | Language | Directory |
|---|---|---|
| Express.js | TypeScript | . |
A2A (Agent-to-Agent) is a pattern where AI agents communicate with each other over HTTP. Each agent exposes a simple API that allows:
All implementations expose the same REST API:
GET /Returns information about the agent.
curl http://localhost:3000/
Response:
{
"name": "Eliza",
"bio": "A helpful AI assistant",
"version": "2.0.0-beta.0",
"capabilities": ["chat", "reasoning", "tool-use"],
"powered_by": "elizaOS"
}
GET /healthHealth check endpoint.
curl http://localhost:3000/health
POST /chatSend a message to the agent and receive a response.
curl -X POST http://localhost:3000/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello, how are you?", "sessionId": "user-123"}'
Response:
{
"response": "Hello! I'm doing well, thank you for asking. How can I help you today?",
"agentId": "eliza-agent-id",
"sessionId": "user-123",
"timestamp": "2024-01-10T12:00:00Z"
}
POST /chat/streamStream a response from the agent (SSE).
curl -X POST http://localhost:3000/chat/stream \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"message": "Tell me a story"}'
cd examples/a2a
bun install
bun run start
Optional: OpenAI API key (enables OpenAI-backed responses):
export OPENAI_API_KEY=your-key
Optional configuration:
PORT - Server port (default: 3000)OPENAI_BASE_URL - Custom OpenAI-compatible endpointOPENAI_SMALL_MODEL - Model for quick responsesOPENAI_LARGE_MODEL - Model for complex responsescd examples/a2a
bun run test
# Agent A calls Agent B
curl -X POST http://agent-b:3000/chat \
-H "Content-Type: application/json" \
-H "X-Agent-Id: agent-a" \
-d '{
"message": "Can you help me analyze this data?",
"context": {"source": "agent-a", "task": "data-analysis"}
}'