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

# Custom Auth and Billing

> Implementing custom authentication and billing on top of Livepeer gateways: clearinghouse patterns, per-user metering, and traditional currency settlement.

export const TableCell = ({children, align = "left", header = false, style = {}, className = "", ...rest}) => {
  const Component = header ? "th" : "td";
  return <Component className={className} style={{
    padding: "0.75rem 1rem",
    textAlign: align,
    border: header ? "none" : "1px solid var(--lp-color-border-default)",
    ...style
  }} {...rest}>
      {children}
    </Component>;
};

export const TableRow = ({children, header = false, hover = false, style = {}, className = "", ...rest}) => {
  const rowId = `table-row-${Math.random().toString(36).substr(2, 9)}`;
  return <>
      {hover && <style>{`
          #${rowId}:hover {
            background-color: var(--lp-color-bg-card);
          }
        `}</style>}
      <tr id={rowId} className={className} style={{
    ...header && ({
      backgroundColor: "var(--lp-color-accent-strong)",
      color: "var(--lp-color-on-accent)",
      fontWeight: "bold"
    }),
    ...style
  }} {...rest}>
        {children}
      </tr>
    </>;
};

export const StyledTable = ({children, variant = "default", style = {}, className = "", ...rest}) => {
  const wrapperVariants = {
    default: {
      border: "1px solid var(--lp-color-border-default)",
      backgroundColor: "var(--lp-color-bg-card)",
      overflow: "hidden"
    },
    bordered: {
      border: "2px solid var(--lp-color-accent)",
      backgroundColor: "var(--lp-color-bg-page)",
      overflow: "hidden"
    },
    minimal: {
      border: "none",
      backgroundColor: "transparent",
      overflow: "visible"
    }
  };
  return <div data-docs-styled-table-shell className={className} style={{
    width: "100%",
    padding: 0,
    margin: 0,
    ...wrapperVariants[variant],
    ...style
  }} {...rest}>
      <table data-docs-styled-table style={{
    width: "100%",
    borderCollapse: "collapse",
    borderSpacing: 0,
    margin: 0,
    backgroundColor: "transparent"
  }}>
        {children}
      </table>
    </div>;
};

export const CenteredContainer = ({children, maxWidth = "800px", padding = "0", preset = "default", width = "", minWidth = "", marginRight = "", marginBottom = "", textAlign = "", style = {}, className = "", ...rest}) => {
  const presets = {
    default: {},
    fitContent: {
      width: "fit-content",
      minWidth: "fit-content"
    },
    readable70: {
      width: "70%",
      minWidth: "fit-content"
    },
    readable80: {
      width: "80%",
      minWidth: "fit-content"
    },
    readable90: {
      width: "90%"
    },
    wide900: {
      maxWidth: "900px"
    }
  };
  const presetStyle = presets[preset] || presets.default;
  return <div className={className} style={{
    maxWidth: presetStyle.maxWidth || maxWidth,
    margin: "0 auto",
    padding: padding,
    ...presetStyle.width ? {
      width: presetStyle.width
    } : {},
    ...presetStyle.minWidth ? {
      minWidth: presetStyle.minWidth
    } : {},
    ...width ? {
      width
    } : {},
    ...minWidth ? {
      minWidth
    } : {},
    ...marginRight ? {
      marginRight
    } : {},
    ...marginBottom ? {
      marginBottom
    } : {},
    ...textAlign ? {
      textAlign
    } : {},
    ...style
  }} {...rest}>
      {children}
    </div>;
};

export const CustomDivider = ({color = "var(--lp-color-border-default)", middleText = "", spacing = "default", style = {}, className = "", ...rest}) => {
  const spacingPresets = {
    default: {
      margin: "24px 0"
    },
    overlap: {
      margin: "-1rem 0 -1rem 0"
    },
    tight: {
      margin: "0 0 -1rem 0"
    },
    section: {
      margin: "0 0 -2rem 0"
    },
    sectionOverlap: {
      margin: "-1rem 0 -2rem 0"
    },
    deepOverlap: {
      margin: "-1rem 0 -1.5rem 0"
    }
  };
  const spacingStyle = spacingPresets[spacing] || spacingPresets.default;
  return <div role="separator" aria-orientation="horizontal" className={className} style={{
    display: "flex",
    alignItems: "center",
    ...spacingStyle,
    fontSize: style?.fontSize || "16px",
    height: "fit-content",
    ...style
  }} {...rest}>
      <span style={{
    marginRight: "var(--lp-spacing-px-8)",
    opacity: 0.2
  }}>
        <Icon icon="/snippets/assets/logos/Livepeer-Logo-Symbol-Theme.svg" />
      </span>
      <div style={{
    flex: 1,
    height: "1px",
    background: "var(--lp-color-border-default)",
    opacity: 0.4
  }}></div>
      {middleText && <>
          <Icon icon="circle" size={2} />
          <span style={{
    margin: "0 8px",
    fontWeight: "bold",
    color: color,
    opacity: 0.7
  }}>
            {middleText}
          </span>
          <Icon icon="circle" size={2} />
        </>}
      <div style={{
    flex: 1,
    height: "1px",
    background: "var(--lp-color-border-default)",
    opacity: 0.4
  }}></div>
      <span style={{
    marginLeft: "var(--lp-spacing-px-8)",
    opacity: 0.2
  }}>
        <span style={{
    display: "inline-block",
    transform: "scaleX(-1)"
  }}>
          <Icon icon="/snippets/assets/logos/Livepeer-Logo-Symbol-Theme.svg" />
        </span>
      </span>
    </div>;
};

export const LinkArrow = ({href, label, description, newline = true, borderColor, className = '', style = {}, ...rest}) => {
  const linkArrowStyle = {
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center',
    gap: "var(--lp-spacing-1)",
    width: 'fit-content',
    ...borderColor && ({
      borderColor
    })
  };
  return <span className={className} style={style} {...rest}>
      {newline && <br />}
      <span style={linkArrowStyle}>
        <a href={href} target="_blank" rel="noopener noreferrer">
          {label}
        </a>
        <Icon icon="arrow-up-right" size={14} color="var(--lp-color-accent)" />
      </span>
      {description && description}
      {description && <div style={{
    height: "var(--lp-spacing-3)"
  }} />}
    </span>;
};

<CenteredContainer preset="readable90">
  <Tip>The remote signer architecture allows a clearinghouse to operate the Ethereum payment layer on behalf of multiple Gateway operators. Gateways settle with the clearinghouse in traditional currency; the clearinghouse handles PM settlement with Orchestrators.</Tip>
</CenteredContainer>

***

The Livepeer Network settles payments between Gateways and Orchestrators using Probabilistic Micropayments in ETH on Arbitrum One. Applications built on top of Gateways typically need a different billing model: per-user metering, subscription tiers, or fiat currency invoicing. These concerns sit between your application and the Gateway, not inside the Livepeer Protocol itself.

<CustomDivider />

## Clearinghouse Operators

The remote signer architecture enables a clearinghouse model: a third-party operator runs the Ethereum-facing signer service and manages ETH deposits on behalf of multiple Gateway operators. Gateway operators settle with the clearinghouse using traditional currency; the clearinghouse handles PM ticket generation and on-chain redemption transparently.

From the Gateway operator's perspective:

* No ETH required in the Gateway process
* No Arbitrum RPC dependency
* No PM bookkeeping in the Gateway implementation
* Bills arrive from the clearinghouse in a traditional currency at agreed intervals

The clearinghouse's `signTicket` HTTP service is the boundary point. It prices compute, validates requests, and signs tickets only for sessions the clearinghouse has authorised.

This is the primary mechanism for third-party Gateway providers (such as community Gateways) to offer Livepeer compute access without requiring every developer to operate their own Arbitrum account.

<CustomDivider />

## Per-User Metering

A Gateway operator running a multi-tenant platform needs to track usage per user to issue invoices, enforce quotas, or implement credit-based billing. This metering layer sits above the Gateway and below the application:

1. **Authentication middleware:** Validate the incoming request (API key, JWT, session token) and associate it with a user account
2. **Usage recording:** Record session start time, pipeline type, and associated user ID
3. **Fee calculation:** At session end or billing cycle close, multiply elapsed seconds by the per-second price
4. **Billing integration:** Push usage records to your billing system (Stripe, internal ledger, etc.)

The Gateway itself does not natively expose per-user accounting. You add this as a proxy layer in front of the Gateway, or by instrumenting the Gateway's webhook callbacks.

For real-time AI sessions, the start and stop of each session provide natural billing events. Subscribe to the `stream.started` and `stream.idle` webhook events (for managed Gateway scenarios) or implement session tracking at the proxy layer.

<CustomDivider />

## Quota and Rate Limiting

Quota enforcement sits in the clearinghouse or authentication proxy, not the Gateway. Patterns:

<StyledTable variant="bordered">
  <thead>
    <TableRow header>
      <TableCell header>Enforcement point</TableCell>
      <TableCell header>Mechanism</TableCell>
      <TableCell header>Suitable for</TableCell>
    </TableRow>
  </thead>

  <tbody>
    <TableRow>
      <TableCell>Clearinghouse `signTicket`</TableCell>
      <TableCell>Refuse to sign tickets when the user's pre-purchased credit is exhausted</TableCell>
      <TableCell>Prepaid compute credit systems</TableCell>
    </TableRow>

    <TableRow>
      <TableCell>Authentication proxy</TableCell>
      <TableCell>Block session start requests based on remaining quota</TableCell>
      <TableCell>Subscription tiers, trial limits</TableCell>
    </TableRow>

    <TableRow>
      <TableCell>Gateway webhook</TableCell>
      <TableCell>Reject streams that exceed per-user session count limits</TableCell>
      <TableCell>Concurrent session caps</TableCell>
    </TableRow>
  </tbody>
</StyledTable>

<CustomDivider />

## Fiat Settlement

When a clearinghouse operator runs the signer on behalf of Gateway operators, fiat settlement replaces direct ETH management for those operators:

* The clearinghouse tracks ETH spending per Gateway operator (derivable from the PM state it manages)
* The clearinghouse invoices operators periodically (weekly, monthly) in USD or another fiat currency
* Operators pay via bank transfer, credit card, or any agreed method
* The clearinghouse replenishes its ETH deposit pool from this revenue

From the Orchestrator side, nothing changes: they receive ETH PM tickets and redeem winners on-chain as normal.

<Note>
  A production clearinghouse requires careful ETH deposit pool management. The clearinghouse's sender deposit in TicketBroker must cover the outstanding expected value of all in-flight tickets across all Gateways it is signing for. Underfunding the deposit causes job rejections across all client Gateways simultaneously.
</Note>

<CustomDivider />

## Related Pages

<CardGroup cols={2}>
  <Card title="Remote Signer" icon="key" href="/v2/developers/guides/payments/remote-signer" arrow horizontal>
    The signer architecture that enables clearinghouse and off-chain Gateway patterns.
  </Card>

  <Card title="ETH Escrow and Deposits" icon="lock" href="/v2/developers/guides/payments/eth-escrow-and-deposits" arrow horizontal>
    Managing TicketBroker deposits for a Gateway or clearinghouse.
  </Card>

  <Card title="Payments Overview" icon="grid" href="/v2/developers/guides/payments/overview" arrow horizontal>
    Payment modes and Gateway deposit flow.
  </Card>

  <Card title="Alt-Gateway Overview" icon="server" href="/v2/developers/build/alt-gateways/overview" arrow horizontal>
    Non-Go Gateway implementations that connect to a clearinghouse signer.
  </Card>
</CardGroup>
