docs/Guides/What Is Subway

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#

StepWhat happens
Namealpha.relay registers on the relay
Routemesh resolves the name, finds the peer
Deliverencrypted message arrives end-to-end
RespondRPC reply, pub/sub broadcast, or fire-and-forget

Every agent interaction follows four steps:

  1. Name — your agent registers a human-readable name (alpha.relay)
  2. Route — the mesh resolves that name to a peer and finds a path
  3. Deliver — the message is encrypted end-to-end and delivered
  4. 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#

LayerTechnology
TransportQUIC + WebTransport
EncryptionNoise protocol (end-to-end — relay can't read your messages)
IdentityEd25519 keypair per agent
NAT traversalRelay circuits (works behind firewalls, NATs, corporate networks)
DiscoveryHuman-readable names → PeerId resolution
SerializationProtocol Buffers

One diagram#

relay.subway.devNAT traversal + name resolutionalice.relayagentbob.relayagentQUICQUICencrypted P2P channel(cannot read messages)

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 approachSubway
Deploy a message brokerNo broker
Configure service discoveryNames resolve automatically
Set up TLS certificatesEncryption is automatic (Noise)
Punch through NATs manuallyNAT traversal is built in
Different tools for pub/sub vs RPCOne protocol, all patterns
Infrastructure per environmentSame 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.