0G Pay
REST API · v1.0.0

Add 0G Pay to your app

A REST API for topping up, reading, and transferring 0G Balances — the on-chain credit system that powers AI services on the 0G network.

A 0G Balanceis a per-wallet credit account held in the 0G Pay contract. Users deposit funds via card or crypto; AI service providers deduct from the balance as they fulfill requests. No API key required — the v1 endpoints are public. The Pay v2 top-up routes are the one exception: they act on one user's balance, so they take that user's session token.

Quick startAPI reference ↓Base URL: https://pay.0g.ai

What you can build

Integration options

Hosted widgetNo-code

Drop-in checkout UI embedded via the 0G Pay SDK. No server required. Best for landing pages and non-React apps.

Best for: landing pages, non-React
Embedded SDKReact

React components with full styling control. Use the 0G Pay SDK for prebuilt deposit and send flows.

Best for: React apps, custom UI
View reference →
REST APIAny platform

Direct HTTP calls documented on this page. No SDK dependency. Works server-side or in any language.

Best for: backends, full control
View reference →

Quick start

From zero to first call in 3 steps

No setup or API key needed — only the Pay v2 top-up routes ask for a session token.

1
No setup required

All requests go to https://pay.0g.ai. No API key, no registration — the only auth header anywhere is the session token the Pay v2 top-up routes take.

2
Read a 0G Balance

Use GET /api/balance to fetch the 0G token balance for any wallet. This is your verify-connectivity call.

3
Set up a deposit flow

Card: fiat/quote → fiat/order → open wrapperUrl in popup. Crypto: buy/prepare → sign → buy/confirm → poll buy/order.

// Install
npm install @0gfoundation/0g-pay-sdk

import { OGPay } from '@0gfoundation/0g-pay-sdk';

// 1. Drop-in deposit button — opens the deposit modal on click
export function App() {
  return <OGPay provider={window.ethereum} />;
}

// 2. Custom trigger element
<OGPay provider={provider}>
  <button>Fund Account</button>
</OGPay>

// 3. Developer mode — route deposits to your own address
<OGPay
  provider={provider}
  mode="developer"
  recipientAddress="0xYourRecipientAddress"
  onSuccess={(data) => console.log('txHash:', data.txHash)}
/>
Full SDK docs on npm →

API Reference

Base URL: https://pay.0g.ai — All responses are JSON. On-chain 0G balances. Amounts are token wei. No API key — every route is public and rate-limited per IP.

Health
Read a balance
List activity
Crypto deposit
Card deposit
GET/api/healthAuth: None120 req/min

Service health check. Returns current timestamp and API version. Useful for monitoring uptime.

curl https://pay.0g.ai/api/health