> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Gateway Architecture

> How gateways fit into the Livepeer stack - layer position, internal components, request flow, system interactions, and the dual video/AI pipeline.

Gateways sit at the application layer of Livepeer. They accept requests from apps, route them to orchestrators, and coordinate payment and failover across the compute and protocol layers.

For what gateways *do*, see [Capabilities](/v2/gateways/concepts/capabilities.md). For why you would run one, see [Business Model](/v2/gateways/concepts/business-model.md).

## Gateway Layer Context

The Livepeer network has three functional layers. Gateways operate at the **application layer**, bridging end-user applications and the compute layer where orchestrators run GPU workloads.

Layered Architecture

```mermaid theme={null}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#1a1a1a', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2d9a67', 'lineColor': '#2d9a67', 'secondaryColor': '#0d0d0d', 'tertiaryColor': '#1a1a1a', 'background': '#0d0d0d', 'fontFamily': 'system-ui', 'clusterBkg': 'rgba(255,255,255,0.05)', 'clusterBorder': '#2d9a67' }}}%%
graph LR
    classDef default stroke-width:2px
    subgraph APP[Application Layer]
        X["User App<br/>Web, Mobile, TouchDesigner"]
    end
    subgraph GW[Gateway Layer]
        G1[Job Intake]
        G2[Capability Discovery]
        G3[Pricing & Selection]
        G4[Routing / Session Mgmt]
    end
    subgraph ORC[Orchestrator Layer]
        O1[GPU Worker]
        O2[AI Models / BYOC Containers]
        O3[Transcoder]
    end
    X --> G1
    G1 --> O1
    O1 --> G1
    G1 --> X
```

<table>
  <tr>
    Layer

    Participants

    Responsibility
  </tr>

  <tr>
    **Application**

    Developers, end users, gateways

    Ingest requests, route jobs, deliver results, manage pricing
  </tr>

  <tr>
    **Compute**

    Orchestrators, transcoders, AI runners

    Execute video and AI work on GPUs
  </tr>

  <tr>
    **Protocol**

    Arbitrum smart contracts

    Staking, payments, governance, orchestrator registry
  </tr>
</table>

Gateways are the only demand-side participants that interact with both the compute layer (sending jobs to orchestrators) and the protocol layer (payment tickets, orchestrator discovery via the on-chain registry).

System Interactions

## Gateway Interactions

A gateway interacts with four categories of actors:

### Applications

Applications are the gateway's customers. They send workloads and receive results.

* Video applications send RTMP streams (port 1935) and receive HLS/DASH output
* AI applications send HTTP requests (port 8935, enabled via `-httpIngest`) and receive JSON/binary inference results
* BYOC applications send custom payloads via HTTP and receive container output

The gateway abstracts orchestration and protocol details for applications. Applications send workloads and receive results through gateway interfaces.

### Orchestrators

Orchestrators are the supply side. The gateway selects, negotiates with, and dispatches work to them.

* **Discovery** - on-chain gateways query the ServiceRegistry contract on Arbitrum; off-chain gateways receive orchestrator lists from the remote signer
* **Negotiation** - the gateway requests an orchestrator's capabilities and price, then establishes a session with an acceptable orchestrator
* **Dispatch** - video segments or AI requests are sent to the orchestrator with an attached payment ticket
* **Failover** - on failure, the gateway retries with the next-best option from its ranked list

### Remote Signer

In the **off-chain operational mode**, the gateway delegates all payment operations to a **remote signer** service. The remote signer:

* Holds the ETH deposit and reserve
* Generates probabilistic micropayment tickets on the gateway's behalf
* Provides orchestrator discovery (list of known orchestrators)
* Handles all on-chain interactions (ticket redemption is on the orchestrator side)

This architecture allows gateways to operate with zero crypto knowledge and zero ETH. See [Remote Signers](/v2/gateways/guides/payments-and-pricing/remote-signers.md) for the full protocol.

### Arbitrum Protocol

In the **on-chain operational mode**, the gateway interacts directly with Arbitrum smart contracts:

<table>
  <tr>
    Contract

    Gateway interaction
  </tr>

  <tr>
    **TicketBroker**

    Fund deposit and reserve; generate payment tickets for orchestrators
  </tr>

  <tr>
    **ServiceRegistry**

    Query registered orchestrators and their service URIs
  </tr>
</table>

> [!NOTE]
>
> Gateways interact with TicketBroker and ServiceRegistry. Orchestrators handle BondingManager, RoundsManager, and Governance interactions.

Internal Architecture

## Dual Pipeline Architecture

The gateway node (`LivepeerNode` in go-livepeer) runs two independent session managers - one for video, one for AI. This allows a single gateway to handle both workload types simultaneously without interference.

Dual Gateway Architecture: Video & AI Pipelines

```mermaid theme={null}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#1a1a1a', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2d9a67', 'lineColor': '#2d9a67', 'secondaryColor': '#0d0d0d', 'tertiaryColor': '#1a1a1a', 'background': '#0d0d0d', 'fontFamily': 'system-ui' }}}%%
flowchart TB
    subgraph INPUT["Input Sources"]
        direction LR
        RTMP["RTMP Stream"]
        HTTP["HTTP Upload"]
        AI_REQ["AI Request"]
    end

    GATEWAY["Gateway Node<br/>LivepeerNode"]

    INPUT --> GATEWAY

    subgraph MANAGERS["Session Managers"]
        direction LR
        BSM["BroadcastSessionsManager<br/>Video Transcoding"]
        ASM["AISessionManager<br/>AI Processing"]
    end

    GATEWAY --> BSM
    GATEWAY --> ASM

    subgraph VIDEO["Video Pipeline"]
        SEG["Segment Processing"]
        ORCH_V["Orchestrators<br/>Transcoding"]
        HLS["HLS/DASH Output"]
    end

    subgraph AI["AI Pipeline"]
        PROC["AI Processing"]
        ORCH_AI["Orchestrators<br/>AI Models"]
        OUT_AI["AI Output<br/>Images/Video"]
    end

    BSM --> SEG --> ORCH_V --> HLS
    ASM --> PROC --> ORCH_AI --> OUT_AI

    subgraph PAYMENT["Payment"]
        direction LR
        PAY_SEG["Per Segment"]
        PAY_PIX["Per Pixel"]
    end

    ORCH_V --> PAY_SEG
    ORCH_AI --> PAY_PIX

    classDef default fill:#1a1a1a,color:#fff,stroke:#2d9a67,stroke-width:2px
    classDef video fill:#1a1a1a,color:#fff,stroke:#3b82f6,stroke-width:2px
    classDef ai fill:#1a1a1a,color:#fff,stroke:#a855f7,stroke-width:2px
    class RTMP,HTTP,BSM,SEG,ORCH_V,HLS,PAY_SEG video
    class AI_REQ,ASM,PROC,ORCH_AI,OUT_AI,PAY_PIX ai
    style INPUT fill:#0d0d0d,stroke:#2d9a67,stroke-width:1px
    style MANAGERS fill:#0d0d0d,stroke:#2d9a67,stroke-width:1px
    style VIDEO fill:#0d0d0d,stroke:#3b82f6,stroke-width:1px
    style AI fill:#0d0d0d,stroke:#a855f7,stroke-width:1px
    style PAYMENT fill:#0d0d0d,stroke:#2d9a67,stroke-width:1px
```

### Video vs AI Pipelines

<table>
  <tr>
    Aspect

    Video pipeline (blue)

    AI pipeline (purple)
  </tr>

  <tr>
    **Session manager**

    `BroadcastSessionsManager`

    `AISessionManager`
  </tr>

  <tr>
    **Input**

    RTMP stream segmented into chunks

    HTTP request with prompt/image/audio
  </tr>

  <tr>
    **Orchestrator work**

    Transcode each segment to output profiles

    Run inference model, return result
  </tr>

  <tr>
    **Output**

    HLS/DASH stream

    JSON (text), image, video clip, or audio
  </tr>

  <tr>
    **Payment unit**

    Wei per pixel (per segment)

    Wei per pixel or per millisecond
  </tr>

  <tr>
    **Session duration**

    Long-lived (entire stream)

    Short-lived (single request or batch)
  </tr>
</table>

Both pipelines share the same orchestrator selection logic, payment system, and failover behaviour. The separation is at the session management layer.

Request Flow

## Job Lifecycle

This is what happens when an application sends a request to a gateway, from intake through result delivery and payment.

Gateway Request Flow

```mermaid theme={null}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#1a1a1a', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2d9a67', 'lineColor': '#2d9a67', 'secondaryColor': '#0d0d0d', 'tertiaryColor': '#1a1a1a', 'background': '#0d0d0d', 'fontFamily': 'system-ui' }}}%%
graph TD
    classDef default stroke-width:2px
    A["Application<br/>Daydream, ComfyUI, BYOC"] -->|Job Request| B["Gateway<br/>Job Intake, Pricing, Capability Match"]
    B -->|Route Job| C["Orchestrator<br/>GPU Compute, AI Inference, Transcoding"]
    C -->|Results| B
    B -->|Response| A
```

### Lifecycle Steps

1. **Job arrives** - An application sends a video segment (RTMP) or AI request (HTTP) to the gateway.
2. **Pipeline routing** - The gateway routes the request to the appropriate session manager (`BroadcastSessionsManager` for video, `AISessionManager` for AI).
3. **Orchestrator selection** - The session manager selects the best orchestrator from its pool based on capability, price, latency, and performance history.
4. **Payment ticket generation** - The gateway (or remote signer in off-chain mode) generates a probabilistic micropayment ticket and attaches it to the job.
5. **Work dispatch** - The job + ticket are sent to the orchestrator over HTTP.
6. **Execution** - The orchestrator routes the work to its GPU worker (transcoder for video, AI Runner for inference) and returns the result.
7. **Result delivery** - The gateway sends the processed output back to the application.
8. **Payment settlement** - The orchestrator accumulates payment tickets and periodically redeems winning tickets on Arbitrum for ETH.

Key Components

## Software Components

### go-livepeer

The core node software. When started in gateway mode (`-gateway`), it runs as the gateway controller. Handles:

* Job intake (RTMP server + HTTP API server)
* Orchestrator discovery and session management
* Payment ticket generation (on-chain operational mode) or remote signer communication (off-chain operational mode)
* Prometheus metrics (port 7935)

Source: [github.com/livepeer/go-livepeer](https://github.com/livepeer/go-livepeer) - specifically [core/livepeernode.go](https://github.com/livepeer/go-livepeer/blob/5691cb48/core/livepeernode.go)

> [!NOTE]
>
> The gateway was previously called the **broadcaster**. Legacy CLI flags still use `-broadcaster` in some contexts. The `-gateway` flag is the current standard.

### livepeer\_cli

A command-line tool that connects to a running go-livepeer node. Used for:

* Setting broadcast configuration (max price, transcoding profiles)
* Funding the on-chain deposit and reserve
* Viewing node status and connected orchestrators

### Remote Signer (off-chain)

A separate service that handles ETH custody and payment ticket signing for off-chain gateways. It runs as a sidecar or external service alongside go-livepeer.

See [Remote Signers](/v2/gateways/guides/payments-and-pricing/remote-signers.md) for architecture and configuration.

### Arbitrum Contracts (on-chain)

<table>
  <tr>
    Contract

    Gateway use
  </tr>

  <tr>
    **TicketBroker**

    Deposit ETH, manage reserve, generate payment tickets
  </tr>

  <tr>
    **ServiceRegistry**

    Discover registered orchestrators
  </tr>
</table>

See [Contract Addresses](/v2/gateways/resources/reference/technical/contract-addresses.md) for deployed addresses.

## Related Pages

> [card] [Gateway Role](/v2/gateways/concepts/role.md)
>
> What gateways are and how the role has evolved.

> [card] [Gateway Capabilities](/v2/gateways/concepts/capabilities.md)
>
> Workload types, orchestrator selection, and session management.

> [card] [Gateway Business Model](/v2/gateways/concepts/business-model.md)
>
> Revenue models, cost structures, and pricing.

> [card] [Payment System](/v2/gateways/guides/payments-and-pricing/payment-guide.md)
>
> How probabilistic micropayments work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.