Client‑agnostic by design. If your client can call an OpenAI‑style HTTP API, it works with Paywalls. In most cases you only change the baseURL and the API key—no proprietary SDK required.Works with: official OpenAI SDKs (Node, Python, .NET, Java), community clients (Go, Ruby, Rust, PHP), and plain HTTP (fetch/axios, curl, Postman). Edge/serverless runtimes are supported.Compatibility surface: Chat Completions (incl. streaming), tools/function‑calling, JSON/structured outputs. Identify the end user via body user (preferred) or header X‑Paywall‑User.
Copy
import OpenAI from "openai";const client = new OpenAI({ apiKey: process.env.PAYWALLS_API_KEY, baseURL: "https://api.paywalls.ai/v1",});const stream = await client.chat.completions.create({ model: "openai/gpt-4o-mini", user: "user_123", stream: true, messages: [ { role: "user", content: "Explain usage-based pricing in 2 lines." }, ],});for await (const chunk of stream) { const delta = chunk.choices?.[0]?.delta?.content; if (delta) process.stdout.write(delta);}
Always send a stable, pseudonymous user id. For browser-only apps, do not
expose your paywall key—use a server, edge function, or proxy.