# Developers

Peerline is a decentralized coordination layer for AI. Whether you are providing compute via a peer node or building autonomous agents with the SDK, the following guides cover everything needed to get started. All integrations are designed to work with existing tooling — no proprietary clients, no account registration, no platform lock-in.

### Node Infrastructure

Run your own peer node, monetize your models, and contribute to the decentralized registry. Peerline seller nodes are the compute backbone of the network. Any machine running a compatible model can register as a provider, advertise its offerings, and begin earning per-request in USDC.

#### Peerline CLI

**Estimated setup time: 1 minute**

The Peerline CLI is the primary tool for managing peer nodes. It handles seller registration, offering advertisement, heartbeat maintenance, and payment channel management from a single command interface. No configuration file is required to get started — the CLI accepts all options as flags and derives sensible defaults for local development.

**Starting a seller node:**

```bash
npx peerline seller
```

This command starts a seller node on the local machine, registers it with the Peerline registry, and begins accepting inference requests. The node will advertise available models and accept per-request USDC payments from buyers on the network.

**Starting with a specific model and tunnel:**

```bash
npx peerline seller --ngrok --model llama3
```

The `--model` flag specifies which model this seller node will serve. The `--ngrok` flag enables automatic tunnel provisioning so the local node is reachable from the global Peerline network without manual port forwarding or firewall configuration.

**Available flags:**

`--model` — specifies the model identifier this seller node will advertise and serve. `--ngrok` — enables Ngrok tunnel provisioning automatically using a stored or provided token. `--use-tunnel` — enables tunnel mode with an explicitly provided token. `--token` — the Ngrok authentication token for tunnel provisioning. `--port` — overrides the default seller port if running multiple nodes on the same machine.

#### Ngrok Tunneling

**Estimated setup time: 2 minutes**

Peerline seller nodes running on local machines or behind NAT need an outbound tunnel to be reachable by buyers across the global network. Peerline integrates directly with Ngrok to provision encrypted tunnels without requiring manual network configuration.

Tunneling is handled at the transport layer — the inference payload is already encrypted end-to-end before it enters the tunnel, so Ngrok sees only ciphertext. The tunnel is used exclusively for reachability, not for security.

**Starting a seller with explicit Ngrok token:**

```bash
peerline seller --use-tunnel --token [NGROK_TOKEN]
```

Replace `[NGROK_TOKEN]` with the authentication token from the Ngrok dashboard at ngrok.com. Once the tunnel is established, the seller's public tunnel URL is automatically registered with the Peerline registry and made available to buyers for routing.

**Notes on tunnel usage:**

Ngrok free-tier tunnels assign a new URL on each restart. For persistent seller node addresses, a paid Ngrok plan with a reserved domain is recommended. Peerline will re-register the updated URL automatically on each restart, but buyers with a cached peer-pin pointing to the old URL will need to re-resolve through the registry.

### Protocol Gateways

Bridge existing LLM tools to the Peerline decentralized network using standard API protocols. Protocol gateways allow applications, agents, and development tools already integrated with OpenAI or Anthropic to route inference through Peerline without changing any application-level code. The gateway handles peer resolution, privacy payload construction, and payment authorization transparently.

#### Local Buyer Proxy

**Estimated setup time: 1 minute**

The local buyer proxy is a drop-in replacement for any OpenAI or Anthropic API base URL. It runs at `localhost:8377` and accepts standard request shapes — `/v1/chat/completions`, `/v1/messages`, and related endpoints — translating them into Peerline's privacy-preserving peer-routed inference requests.

Any application, script, or tool that accepts a configurable base URL can be pointed at the local buyer proxy with a single environment variable change. No code modifications are required.

**Configuring the proxy as the OpenAI base URL:**

```bash
export OPENAI_BASE_URL=http://localhost:8377/v1
```

Once this environment variable is set, all OpenAI SDK calls in the current shell session will route through the Peerline buyer proxy. The proxy resolves the best available seller from the registry, constructs the encrypted request payload, manages the x402 payment authorization, and streams the response back — all transparently.

**What the proxy handles automatically:**

Peer resolution against the decentralized registry. Privacy payload construction including ZK proof generation and AES payload encryption. x402 payment channel creation and SpendingAuth signing on 402 responses. Retry logic on payment negotiation. Response streaming back to the calling application.

The calling application sees a standard OpenAI-compatible response. The entire Peerline protocol interaction is invisible from the application layer.

#### Registry API

**Access type: Raw HTTP**

The Peerline registry exposes a raw HTTP API for querying the decentralized provider registry directly. This is useful for applications that want to inspect available peers, compare pricing across providers, build custom routing logic, or monitor network liveness without running a full buyer proxy.

**Querying all active peers:**

```bash
curl http://localhost:9000/peers
```

This returns a JSON array of all currently registered and live seller peers, including their advertised offerings, per-token pricing, supported model IDs, and endpoint addresses. The registry prunes stale peers automatically based on heartbeat lapse, so the response reflects only nodes that are currently active and reachable.

**Typical use cases for direct registry access:**

Comparing per-token pricing across providers before committing to a channel. Building a custom buyer client outside the standard SDK. Monitoring network health and active node count. Filtering providers by model ID, capability type, or pricing constraints for cost-optimized routing. Integrating Peerline peer discovery into external orchestration systems or agent frameworks.

The registry API requires no authentication for read queries. Write operations — registration and heartbeat — are performed by the seller CLI and SDK automatically.

### Next Steps

Once a node is running or a buyer proxy is configured, the following resources cover the deeper protocol layers:

**docs.peerline.ai** — full protocol documentation covering the privacy stack, x402 payment model, ZK proof mechanics, and SDK reference.

**@AskPeerline** on X — protocol updates, network announcements, and integration support at <https://x.com/AskPeerline>.


---

# 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.peerline.ai/integrations/developers.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.
