# How Inpherio works — the architecture

Source: https://inpherio.co.uk/how-it-works

How it works

# How Inpherio works.

A hub-and-spoke proxy that connects consumers who need inference with operators with idle hardware — GPUs, Macs, mini PCs, even CPUs — without anyone opening a port, trusting a stranger, or changing their network.

## The big picture.

Three parties, one encrypted path, zero inbound ports.

### Consumer

Sends a standard OpenAI-compatible API request to the Inpherio master server. No knowledge of which node serves it, where that node is, or how it's configured. One URL, one API key.

### Master server

The hub. Authenticates consumers, matches requests to the best available node, proxies traffic through the tunnel, counts tokens, bills, and handles failover. Never stores prompt content.

### Node agent

The spoke. A lightweight Python client on the operator's machine. Opens one outbound WebSocket to the master, proxies requests to the local inference engine, reports hardware status. No inbound ports.

## The connection: outbound-only tunnels.

The biggest infrastructure problem in distributed inference is NAT traversal — consumer-grade machines sit behind routers that block inbound connections. Inpherio solves this by having the node agent initiate a single outbound WebSocket connection (WSS — WebSocket over TLS) to the master server and hold it open as a bidirectional tunnel.

The operator never opens a port, configures port forwarding, or touches their router. The tunnel is the only path in or out. When a consumer makes a request, the master routes the payload through the existing tunnel to the node agent, which forwards it to the local inference engine on localhost.

### What the tunnel carries

- Authentication handshake (node secret key + hardware fingerprint)
- Heartbeats with live VRAM and model status
- Inference requests (chat, TTS, STT) from consumers
- Streaming response chunks (SSE) back to the master
- Benchmark commands and results

### What the tunnel doesn't carry

- No direct consumer-to-node traffic — the master is always in the path
- No file system access — the agent only proxies to allowlisted localhost ports
- No arbitrary code execution — inference only, no shell commands
- No prompt content is persisted — processed in memory, then dropped

## Authentication: three layers, no shared secrets on the wire.

### 1. Node secret key

On registration, the operator generates a node secret key from the dashboard. The connector reads it from a key file, an environment variable, or a command-line flag (the key file is preferred — it keeps the secret off the process list). The key is presented once during the tunnel handshake, inside the TLS-encrypted WebSocket; the server stores only a SHA-256 hash of it, so a database leak can't reveal your key.

### 2. HMAC message authentication

After the tunnel is established, the master and node agent share a session secret. Every message in both directions is signed with HMAC-SHA256 and timestamped. Messages with stale timestamps or invalid signatures are rejected. This prevents replay attacks and message injection even if the TLS layer is somehow breached.

### 3. Challenge-response heartbeats

Every 10 seconds, the master sends a random challenge nonce. The node agent must respond with the HMAC of that challenge using the session secret. A forged heartbeat without the secret is rejected — this proves the agent is alive and is the same agent that established the tunnel, not a hijacker.

## Hardware verification: fingerprinting without surveillance.

When a node agent connects for the first time, it generates a SHA-256 hash from four hardware components: the CPU model string, total physical RAM, the primary network interface's MAC address, and all GPU UUIDs (read from the GPU's own firmware via nvidia-smi on NVIDIA hardware). This hash is registered with the master.

On every reconnection, the agent recalculates the hash and reports it. If the same hardware fingerprint shows up on a different account — one machine registered under several operators — the platform flags it for admin review, and the admin panel surfaces duplicate-hardware accounts. Consumers never see the fingerprint or raw identifiers like MAC addresses; listings show only a hardware summary (GPU model, VRAM).

This is aimed at fee-free-period abuse and Sybil setups (registering many fake nodes) — combined with the signup IP and hostname recorded at registration.

## Matchmaking: how the master picks a node.

When a consumer request arrives, the master runs a scoring algorithm across all online nodes that have the requested model. Each candidate gets a weighted score:

### Scoring factors

- **Warm status (35%)** — Is the model already loaded in memory? Warm nodes answer straight away; a cold model has to load first, which can take from seconds to a minute or more.
- **Health score (25%)** — A 0-100 composite of uptime, failover rate, benchmark performance, and how many models the engine actually has loaded in memory. Recomputed every 5 minutes.
- **Price fit (20%)** — How close to the cheapest eligible node, within the consumer's budget. Cheaper is better, but not at the cost of reliability.
- **Speed (20%)** — The node's measured tokens per second for this model, from its own benchmark — so a cheap but very slow machine doesn't win on price alone.

### Filters applied before scoring

- Node must be **online** (not paused, rented, suspended, or banned)
- Node must have the **requested model** in its endpoint list
- The model must **fit on the card** — listings larger than the node's total VRAM are skipped
- Price must be within the consumer's **budget** (if set)
- Health score must meet the consumer's **min_reliability** floor (if set)
- Node must not be at **concurrency cap** (operator-set max)

The highest-scoring node gets the request. If it fails, the master tries the next candidate — this is failover.

## Streaming: real-time tokens through the tunnel.

When a consumer requests `stream: true`, the master sends the request through the tunnel with a streaming flag. The node agent opens a streaming HTTP connection to the local inference engine (Ollama, vLLM, llama.cpp, MLX or any other supported engine) and relays each SSE chunk back through the tunnel as it arrives. The master forwards each chunk to the consumer immediately — no buffering, no waiting for the full response.

This means a consumer watching a thinking model (like Qwen3) sees reasoning tokens appear in real time, one by one, as the model generates them. The latency the consumer experiences is the model's generation latency plus the tunnel round-trip — typically under 100ms overhead on top of the model's own speed.

## Multi-format API: one tunnel, three protocols.

Consumers don't need to know what engine powers a node. The master accepts three API formats and translates between them internally:

### OpenAI-compatible

`POST /v1/chat/completions` — the standard format. Works with any OpenAI SDK by changing the base URL. Streaming (SSE) and non-streaming both supported.

### Anthropic Messages

`POST /v1/messages` — the Anthropic Messages API format. The master translates the request to OpenAI format, sends it through the tunnel, and translates the response back to Anthropic format.

### Ollama native

`POST /api/chat` — Ollama's native API. Same translation approach — the consumer speaks Ollama, the master speaks OpenAI to the node, and translates back.

All three formats share the same authentication, matchmaking, billing, failover, and content moderation. The consumer picks the format their SDK speaks; the master handles the rest.

## Beyond text: TTS and STT through the same tunnel.

The tunnel isn't limited to text generation. Two additional endpoints are proxied through the same infrastructure:

### Text-to-speech

`POST /v1/audio/speech` — the consumer sends text, the master routes to a node running a speech model (Kokoro, Piper, Coqui and others), the node generates audio, and the master returns it in the format the engine produced. Audio is base64-encoded through the tunnel and decoded on the master before delivery.

### Speech-to-text (Whisper)

`POST /v1/audio/transcriptions` — the consumer uploads an audio file, the master base64-encodes it and sends through the tunnel, the node runs Whisper and returns the transcription. Same failover, same matchmaking. TTS and STT are billed on the length of the audio — the speech produced, or the recording transcribed — to the second (1-second minimum), at the model's price per hour of audio. The master reads the length from the audio itself (WAV, MP3, FLAC, Ogg/Opus, AAC, M4A, WebM); if a format can't be read it estimates from the text (TTS) or the node's measured speed (STT), and the response says which in `X-Inpherio-Audio-Measured`.

## Metering and billing: trust the model, verify the charge.

Because all traffic flows through the master, the master is the source of truth for billing. Two metering models operate side by side:

### Per-token billing

For OpenAI-compatible endpoints that return a usage block, the master extracts `prompt_tokens` and `completion_tokens` from the response. The consumer is charged purely on usage, with no base fee: `(prompt_tokens × input_price_per_1M + completion_tokens × output_price_per_1M) ÷ 1,000,000`. Operators set separate per-million-token input and output prices — they can charge more for generation than for prompt processing. If an engine returns no usage data, tokens are estimated from the text actually served (~4 characters per token) — engine-reported counts always take precedence.

### Per-second billing

**Speech (TTS/STT)** is billed on audio length: `audio_seconds` (rounded up, at least 1) `÷ 60 × price_per_minute_of_audio`, no base fee. Prices are shown per hour of audio; if a model has no price set, the platform default of £0.18 per hour applies. **Per-second text endpoints** (an operator option) are billed on wall-clock processing time from when the request enters the tunnel to when the last byte returns, the same way, at the endpoint's per-minute price.

Every charge is an atomic database transaction — the consumer's balance is debited and the operator's earnings are credited in the same transaction, or neither happens. The platform fee (15%, waived for your first 12 months or until you have earned £250 fee-free, whichever comes first for new operators) is deducted from the operator's share. The billing ledger is append-only — entries are never edited or deleted, only corrected by a new, audited entry.

## Failover: when a node dies mid-response.

Consumer hardware is unreliable. Nodes drop. Tunnels break. Inpherio handles this gracefully:

1. **Detection.** The node agent sends a challenge-response heartbeat every 10 seconds. A missed beat past 30 seconds raises an alert; around 45 seconds of silence (admin-adjustable) marks the node offline and removes it from the routing pool.
1. **Request-time failover.** If the chosen node is unreachable or errors when the request is dispatched, the master increments its failover counter and re-sends the original request to the next-best candidate. The consumer sees a brief latency spike instead of an error.
1. **Mid-stream drops.** If a node fails before it has sent any of the reply, the proxy sends your request to the next-best node and you see a brief pause. If it fails after the reply has started arriving, the stream ends with a clear error event instead of being replayed — a replay would send you the start of the reply twice — and nothing is charged for it; retry and the request routes around the failed node.
1. **Billing.** Failed attempts that never produced a response cost nothing. You are billed once, for the node that actually served your request.
1. **Health impact.** Each failover lowers the node's health score, which lowers its matchmaking priority. Nodes that failover frequently get less traffic. The market self-corrects.

Non-streamed responses carry an `X-Inpherio-Failover` header telling you whether a re-route happened, and `X-Inpherio-Failed-Nodes` says how many nodes failed before one completed it. A streamed response sends its headers before any failover can happen, so its re-routes are recorded on the request in your usage history instead.

## Node states: the full lifecycle.

Every node moves through a state machine. The master tracks and enforces these states in real time:

### Online

Connected, authenticated, accepting requests. The only state eligible for matchmaking.

### Online and busy

Online with requests in flight — not a separate state. Still eligible for matchmaking until it reaches the concurrency cap its operator set.

### Paused

Operator clicked Pause. In-flight requests finish, no new requests are routed. The operator's GPU is theirs again.

### Suspended

Operator clicked Suspend. Hard pause — no new requests at all. Used when the operator needs guaranteed exclusive access.

### Rented

A consumer has exclusively leased this node for a time period. No other consumer can use it. The rental countdown starts the moment they commit. [More on rentals →](https://inpherio.co.uk/rentals)

### Self-serve

The operator is using their own node through a self-serve key. It leaves the public pool so no one else is routed to it, then rejoins the marketplace automatically once the operator's grace window elapses. [More on self-serve →](https://inpherio.co.uk/self-serve)

### Retired

Decommissioned by the operator. Kept for billing history but excluded from heartbeats, the marketplace, and matchmaking. Registering a fresh node brings the hardware back.

### Locked / Offline

Locked: banned by an admin (hardware mismatch, abuse, terms violation). Offline: tunnel disconnected, heartbeat missed.

## Benchmarking: measuring what every model can actually do.

Every model on a node is benchmarked individually before it joins the marketplace — a model that hasn't passed its own benchmark is never routed to. When a node connects (and whenever a new model is detected, or the hardware changes), each model is queued and measured one at a time. For a fair, repeatable test, the engine is first asked to unload everything it has in memory, then the model is measured twice:

- **Cold start** — time to the first response including loading the model from disk. This is the delay a consumer would feel hitting a cold model.
- **Warm performance** — the same test again with the model loaded. For LLMs this gives **TTFT (Time To First Token)** and **TPS (Tokens Per Second)**; text-to-speech measures generation speed (characters per second), speech-to-text measures a realtime factor (audio seconds transcribed per second of processing), and embedding models measure round-trip latency.

Warm LLM metrics are combined into a 0-100 benchmark score, and the node's tier comes from its best-scoring model: L1 (score ≥ 75, high-performance), L2 (score 50-74, mid-range), L3 (score < 50, budget). Operators can re-benchmark any model — or everything — at any time from the dashboard; a model briefly leaves the marketplace while it re-runs and returns as soon as it passes. Per-model benchmark results are published on the marketplace and on every provider profile.

## Health score: reputation that's earned, not bought.

Every node has a health score from 0 to 100, recomputed every 5 minutes from these components: 30% uptime over 7 days, 25% requests completed without dropping, 20% benchmark speed, 15% models kept loaded and 10% uptime over 30 days.

### What raises the score

- High uptime (7-day and 30-day rolling windows)
- Low failover rate (few mid-request drops)
- Strong benchmark performance (TTFT + TPS)
- Keeping models warm — loaded status is reported live by your inference engine, not self-declared

### What lowers the score

- Downtime (missed heartbeats, tunnel drops)
- Failovers (dropping mid-request)
- Weak benchmark results (slow TTFT, low TPS)
- Cold models (nothing loaded, every request needs a load delay)

The score uses exponential decay — recent performance matters more than old performance. A node that was great three months ago but unreliable now has a declining score. Consumers can filter by health score and see the full breakdown on every provider profile.

## Node rental: exclusive access without a VPS.

Consumers can rent a specific node for a fixed duration — whichever durations its operator offers, from 1 to 168 hours (the default set is 1, 6, 12 or 24 hours). During the rental:

- The node is bound to the renting consumer's API key — no other consumer can use it
- The operator cannot pause or suspend the node (they've committed it for the rental period)
- The consumer gets all the node's models and endpoints at full throughput
- Billing is a flat rate per hour, charged upfront — API usage on the rented node is covered by it, with no per-token or per-second charges on top
- If the node goes down during the rental, the consumer gets a pro-rated refund for the remaining time
- The rental countdown starts the moment the consumer commits — not when they start using it

This bridges the gap between the shared marketplace (cheap, best-effort) and dedicated hosting (expensive, guaranteed). A consumer who finds a node they like can lock it in for their batch job tonight.

## Operator self-serve: use your own node for free.

An operator can be their own consumer. Self-serve mints a **node-scoped API key** that routes only to one node, is never billed, and works only while that operator owns the node and self-serve is enabled. It turns any node into a private, OpenAI-compatible endpoint the operator can call from anywhere.

- **It leaves the marketplace.** The first self-serve request locks the node into a `self_serve` state and removes it from the public pool, so paying traffic is never routed to it mid-session.
- **It reserves on a sliding window.** Each request renews the hold by the operator's grace window (10 minutes by default, settable from 1 minute to 6 hours). One reservation lasts at most 6 hours in a row; the next request reserves the node again.
- **It returns on its own.** When the window elapses with nothing in flight — or the ceiling is hit — the node rejoins the marketplace and its models go live again. The operator can also hand it back immediately; an in-flight request finishes first.
- **It's counted, never charged.** Self-serve usage is logged (requests, tokens, latency) so operators can see throughput, but the charge is always zero — it runs on their own hardware.
- **It's fenced off from the rest.** A rented node can't be self-served until the rental ends; a paused node must be resumed first; retiring or disabling self-serve revokes the keys and releases the node at once.

[Read the full self-serve guide →](https://inpherio.co.uk/self-serve)

## Content moderation: scanning without storing.

Before a request reaches a node, its prompt is screened by **Llama Guard**, an open safety-classifier model, backed by a blocklist of known-bad patterns. The check runs in memory: we keep only a fingerprint (a SHA-256 hash) and the length of each screened prompt, with the verdict — never the text itself.

How strictly it applies depends on the traffic. Requests to [free models](https://inpherio.co.uk/free-terms) are blocked when the classifier judges them unsafe: a chat request gets an ordinary reply that explains the refusal, nothing is sent to a model and nothing is charged — and if the classifier is unavailable, free requests are refused rather than sent unchecked. Paid traffic is currently screened in monitoring mode: verdicts are recorded so the classifier can be tuned on real traffic, but requests are not blocked. We'll say so here before that changes.

Unlawful use is banned outright by the [acceptable use policy](https://inpherio.co.uk/acceptable-use) and enforced at the account level.

## Rate limiting: protecting the platform.

The master enforces Redis-based sliding-window rate limits:

- **Per API key:** 60 requests per minute on `/v1/chat/completions`
- **Per IP:** 30 requests per minute on `/v1/models`
- **Per-key spend budgets:** consumers can set a daily, weekly, or monthly spend cap per API key — requests are refused with HTTP 429 once the cap is reached, until the period resets

Rate limit headers (`X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`) are returned on rate-limited routes. When exceeded, HTTP 429 with a `Retry-After` header.

## Caching: keeping the hot path fast.

The master caches frequently-accessed data in Redis with a 30-second TTL:

- Model lists (the `/v1/models` response)
- Matchmaking candidates (per-model node lists with scores)
- Marketplace model listings and provider profiles

Caches are invalidated the moment a node connects or disconnects — stale data is never served. The hot path (a chat completion request) touches the database only for auth, credit check, and billing — everything else is served from Redis.

## Monitoring: the admin's view.

The admin dashboard is a live operations console, not a static report. It auto-refreshes:

### Live data (auto-refresh)

- Activity feed — last 20 requests with model, node, consumer, latency, cost
- Load graph — requests per minute, last 30 minutes
- Per-node active request count and status
- System health — DB, Redis, tunnel count, error rate

### Background monitoring (every 60s)

- DB and Redis connectivity checks
- Node heartbeat age (missed heartbeats)
- Failover rate per node
- Error rate (failed requests / total)
- Automatic admin alerts via notification inbox

Every admin action — banning a node, refunding a charge, creating a voucher, changing platform config — is recorded in an append-only audit log.

## Fee-free period: 12 months fee-free (up to £250 of earnings).

New operators have the 15% platform fee waived for your first 12 months or until you have earned £250 fee-free, whichever comes first. The clock starts when they add their first node. In that time they keep 100% of what consumers pay for their compute — but the payout fee (£2 + 1% per payout to a UK bank account, £2 + 2% to any other country) still applies each time they are paid out, fee-free period or not. Self-serve use of your own node is always free and never counts towards the limit. After that, the standard 15% platform fee applies.

To prevent abuse, the platform records the signup IP address and hostname on registration, and checks hardware fingerprints across accounts. If the same hardware or IP appears on a new account with an active fee-free period, the admin is notified for review. The fee-free period is configurable from the admin panel and can be disabled entirely.

## Connector updates: automatic, signed and reversible.

The connector keeps itself up to date. It checks for a new version when it starts and about every 30 minutes after that, spread out so the whole network never restarts at once. Before a new version replaces the running one, the connector checks that it is **signed** with Inpherio's release key (made when the release is built — the key isn't kept on our servers), that its checksum matches, that it compiles and that it passes a self-test on that very machine. It installs only when the node is idle, letting anything in flight finish first.

If a new version crashes or can't connect, the connector rolls itself back to the previous one and never installs that version again. Operators can turn automatic updates off in their connector settings and update with one click from the dashboard instead. More on [how the connector updates](https://inpherio.co.uk/connector#updates).

## Ready to see it in action?

Inpherio is in beta. Sign up, connect a machine, or grab an API key and start making requests.

 [Sign up](https://inpherio.co.uk/login) [Browse the marketplace](https://inpherio.co.uk/marketplace)
