Usage Gate

Start

Quickstart

Five steps to enforce access for your end users. Prefer an AI coding agent? Use the setup prompt.

1. Create your workspace

Sign up at /signup with your company name. The dashboard is for you — not your customers.

2. Draw access rules

In Access rules, connect Plan → Feature → Limit (e.g. Free includes ai_credits at 1,000 / month). Full guide: Define access rules.

3. Create an API key

Dashboard → API keys → Generate. Set env:

.env
USAGEGATE_KEY=gk_...
USAGEGATE_API_BASE_URL=http://127.0.0.1:43123

4. Install the SDK and gate a request

terminal
npm install @usagegate0/sdk
your-app.ts
import { GateClient } from "@usagegate0/sdk";

const gate = new GateClient(process.env.USAGEGATE_KEY!, {
  baseUrl: process.env.USAGEGATE_API_BASE_URL,
  failOpen: true,
});

// customerId = YOUR end user (not you)
const ok = await gate.canAccess(customerId, "ai_credits");
if (!ok) return Response.json({ error: "upgrade" }, { status: 402 });

await gate.consume(customerId, "ai_credits", 1);

On signup, seed free-tier balances with gate.grant(userId, "ai_credits", { balance: 1000 }). More: Add the SDK.

5. Connect Stripe (required)

Point your Stripe webhooks at POST /api/webhooks/stripe, save the signing secret on Stripe. Paid refills and the billing period end (resetAt) come from Stripe — see Connect Stripe and billing periods.

6. Watch

Overview shows checks and burns. End users lists balances for people in your product.