What is Subway
One sentence, one diagram, one code sample. Everything you need to know about Subway in 60 seconds.
Subway is a peer-to-peer networking layer for AI agents. Agents name themselves, find each other, and communicate — no servers, no brokers, no infrastructure.
The loop#
| Step | What happens |
|---|---|
| Name | alpha.relay registers on the relay |
| → Route | mesh resolves the name, finds the peer |
| → Deliver | encrypted message arrives end-to-end |
| → Respond | RPC reply, pub/sub broadcast, or fire-and-forget |
Every agent interaction follows four steps:
- Name — your agent registers a human-readable name (
alpha.relay) - Route — the mesh resolves that name to a peer and finds a path
- Deliver — the message is encrypted end-to-end and delivered
- Respond — the receiver replies (RPC), broadcasts (pub/sub), or just receives (fire-and-forget)
No DNS. No service discovery. No TLS certificates. No load balancers.
Five primitives#
That's it. The entire API:
send → fire-and-forget message to a named agent
call → RPC — request/response with timeout
broadcast → publish to all subscribers on a topic
subscribe → listen to a topic (wildcards: metrics.*)
resolve → look up an agent's peer ID by name
Everything else — orchestration, tool calling, task management — is built on top of these by your application.
One code sample#
Two agents. One message. Under 60 seconds.
# Terminal 1: start alice
subway agent --name alice.relay
# Terminal 2: send a message
subway send alice.relay "hey alice, we're on the mesh"alice.relay: hey alice, we're on the mesh
No server to deploy. No broker to configure. No API keys.
What's under the hood#
| Layer | Technology |
|---|---|
| Transport | QUIC + WebTransport |
| Encryption | Noise protocol (end-to-end — relay can't read your messages) |
| Identity | Ed25519 keypair per agent |
| NAT traversal | Relay circuits (works behind firewalls, NATs, corporate networks) |
| Discovery | Human-readable names → PeerId resolution |
| Serialization | Protocol Buffers |
One diagram#
The relay handles discovery and NAT traversal. Messages are encrypted end-to-end — the relay facilitates connections but cannot read traffic. Once peers know each other, communication is direct.
How Subway is different#
| Traditional approach | Subway |
|---|---|
| Deploy a message broker | No broker |
| Configure service discovery | Names resolve automatically |
| Set up TLS certificates | Encryption is automatic (Noise) |
| Punch through NATs manually | NAT traversal is built in |
| Different tools for pub/sub vs RPC | One protocol, all patterns |
| Infrastructure per environment | Same code works anywhere |
Where it fits#
Subway is the networking layer — it handles how agents find each other and communicate. It's complementary to:
- MCP (tool integration) — connect models to tools and data
- A2A (task coordination) — structured collaboration between agent systems
- LangGraph / CrewAI (orchestration) — define how agents think and plan
Subway is what connects them all across machines and networks.
Install and try#
# Install the CLI
brew install subway-dev/tap/subway
# or
curl -fsSL https://subway.dev/install.sh | sh
# Start an agent
subway agent --name my-agent.relay✅ Works today. No waitlist, no tokens, no sign-up.