# Communication

In this section, we'll focus on how peers communicate with one another. Once peers are in the subnet and connected to the cluster of nodes from the bootstrap node, they need a way to communicate with one another. There are two main ways to communicate: using a **GossipSub**, a direct P2P stream using a **custom protocol**, or a direct P2P stream using the **API protocol**.

## [GossipSub](/copy-of-subnet-template/communication/gossipsub.md)

Most communication should be done via a gossip protocol. A gossip protocol is a message distribution system for distributed networks. In a GossipSub, when a peer broadcasts a message, all other peers that should get that message receive it, such as all of the peers, certain roles, or subsets of peers.

## Direct P2P Protocols

Communication can be done directly between two peers by opening a stream between the peers. This can be done by building a custom P2P protocol purpose-built for the use case, or by using the API protocol.

Build a **custom protocol** for communication requirements where the task or data is located in the same process as the subnet template.

For use cases where a peer is running multiple processes, such as LLMs being hosted on multiple servers, use the **API Protocol**.

### [P2P Protocol (Custom)](/copy-of-subnet-template/communication/p2p-protocol.md)

Building a custom protocol is for use cases for communication, where a peer may want to get data from specific peers; they can contact them directly via a custom protocol.

### [API Protocol](/copy-of-subnet-template/communication/api-protocol.md)

The API protocol is a prebuilt protocol that is best for use cases where a peer's business logic is in a separate process, local or remote. The API protocol is set up so that when a peer is called by another peer, the peer that is called will make an API request to a separate process hosting an API based on the API configuration.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertensor.org/copy-of-subnet-template/communication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
