Meet Paywalls.ai: a programmable paywall and usage-based billing proxy for OpenAI-compatible APIs. Route your requests through the proxy to add pricing rules, authorization, and real-time charging—without rebuilding billing or metering.
Production API base URL: https://api.paywalls.ai/v1

Get started in minutes

1

Create an API key

Sign up and create a paywall in the Dashboard. Copy the secret API key.
2

Point your client to the proxy

Replace your OpenAI base URL and key with Paywalls.ai.
import OpenAI from "openai";

const client = new OpenAI({
apiKey: process.env.PAYWALLS_API_KEY, // sk-paywalls-...
baseURL: "https://api.paywalls.ai/v1",
});

const res = await client.chat.completions.create({
model: "openai/gpt-5",
user: "user_123", // or use X-Paywall-User header
messages: [{ role: "user", content: "Hello!" }],
});

console.log(res.choices[0]?.message?.content);

3

Identify the user on every request

Pass a stable user ID via request body (user) or header (X-Paywall-User).This enables authorization and billing.
Learn more: User Identity
4

Handle paywall responses

  • Not authorized → you’ll get an authorization URL
  • Low balance → you’ll get a top-up URL
  • Authorized + funded → request is billed and proxied to the model

Why Paywalls.ai

  • Drop-in OpenAI compatibility (no SDK lock-in)
  • Real-time cost control and guaranteed margins
  • Works with any stack: code and no-code
  • Monetize anywhere: frontends, backends, agents, and MCP tools

What happens on each request

  1. Authenticate your paywall via Bearer API key
  2. Extract user ID (body, header, or URL)
  3. Check authorization and balance; return actionable links if needed
  4. Compute and charge per your pricing rules (per-request and/or per-token)
  5. Forward to the provider and stream results back

Explore next