> For the complete documentation index, see [llms.txt](https://docs.podtorrent.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.podtorrent.com/getting-started/how-it-works.md).

# How PodTorrent works

Three pieces work together.

```
your app ──HTTPS──► PodTorrent gateway ◄══ secure link ══ agent ──► operator's engine
```

* **The gateway** (`api.podtorrent.com`) is the only address your app talks to. It checks your API key, picks a node, and streams the answer back.
* **A node** is one operator's machine (or cluster) running an OpenAI-compatible inference engine.
* **The agent** is a small program the operator runs next to their engine. It keeps a link open to the gateway and passes requests through.

## What happens to one request

1. Your app sends `POST /v1/chat/completions` with a model name.
2. The gateway finds the nodes that serve that model, at a price you accept, with a free slot.
3. It picks the best one (see [Routing and queueing](/concepts/routing.md)) and forwards your request unchanged.
4. The node's engine answers. The answer streams back to you through the agent and the gateway.
5. The gateway records token counts and timings. It never stores your prompt or the answer.

If every suitable node is busy, your request waits a short time for a slot instead of failing straight away.

## Why it's built this way

* **Operators keep control.** They choose their models, how many requests to take at once, and their price.
* **Nodes don't need open ports.** By default the agent dials out, so it works behind NAT and strict firewalls.
* **Both sides keep receipts.** The node and the network each sign what they saw for every request. See [Receipts and billing](/concepts/receipts-and-billing.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.podtorrent.com/getting-started/how-it-works.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
