Getting Started
Set up your AI project with billing in 4 steps.
Step 1: Create a Project
- Sign up at the Dashboard and create a new project
- Note your gateway URL (
gateway.assistant-billing.dev) or configure a custom domain - Go to Settings > Platform and generate a platform key (
sk_pj_*) - Go to Providers and add at least one AI provider (OpenAI, Anthropic, Google, etc.)
# Save your platform key
ASSISTANT_BILLING_PLATFORM_API_KEY=sk_pj_live_abc123Step 2: Install the SDK
npm install @assistant-billing/sdkStep 3: Create Sessions and Proxy Requests
After authenticating a user with your own auth system, use BillingClient to create a session and GatewayClient to make AI requests.
import { BillingClient, GatewayClient } from "@assistant-billing/sdk"
// Server-side: create a session for your customer
const billing = new BillingClient({
platformKey: process.env.ASSISTANT_BILLING_PLATFORM_API_KEY,
workspaceId: "ws_team_123",
userId: "user_456",
})
const { token, expires_at } = await billing.sessions.create()
// → { token: "sess_eyJhbG...", expires_at: "2026-03-15T00:00:00Z" }
// Make an AI request on behalf of the customer
const gateway = new GatewayClient({
apiKey: "sk_ab_live_xyz789",
baseURL: "https://gateway.assistant-billing.dev",
})
const response = await gateway.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
})Constructor Options
BillingClient
| Option | Type | Default | Description |
|---|---|---|---|
platformKey | string | ASSISTANT_BILLING_PLATFORM_API_KEY env | Platform key (sk_pj_*) |
workspaceId | string? | — | Customer workspace identifier |
userId | string? | — | User performing the action |
baseURL | string? | https://api.assistant-billing.dev/v1/platform | Platform API URL |
getToken | () => Promise<string>? | — | Session token callback (client-side auth) |
timeout | number? | 30000 | Request timeout in ms |
GatewayClient
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | ASSISTANT_BILLING_GATEWAY_API_KEY env | Gateway API key (sk_ab_*) |
baseURL | string? | https://gateway.assistant-billing.dev | Gateway URL |
appTitle | string? | — | App name (sent as X-Title header) |
appUrl | string? | — | App URL (sent as HTTP-Referer header) |
defaultHeaders | Record<string, string>? | — | Extra headers for every request |
timeout | number? | 60000 | Request timeout in ms |
Step 4: Add Billing UI
Install the React component library to build a customer-facing billing UI.
npm install @assistant-billing/reactimport { GatewayClient } from "@assistant-billing/react"
import { BillingClient } from "@assistant-billing/sdk"
const client = new BillingClient({
baseURL: "https://api.assistant-billing.dev/v1/platform",
getToken: () => fetchSessionToken(), // return the token from Step 3
})
export default function BillingPage() {
return <GatewayClient client={client} />
}The GatewayClient component renders wallet balance, API key management, and provider key management out of the box.
Next Steps
- How It Works — Architecture, routing, and billing flows
- SDK — Full
BillingClient,GatewayClient, andAdminBillingClientreference - Stripe Setup — Connect Stripe for customer payments
- API Reference — Platform API and Client API endpoints