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.
What you can build
Integration options
Drop-in checkout UI embedded via the 0G Pay SDK. No server required. Best for landing pages and non-React apps.
React components with full styling control. Use the 0G Pay SDK for prebuilt deposit and send flows.
Direct HTTP calls documented on this page. No SDK dependency. Works server-side or in any language.
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.
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.
Use GET /api/balance to fetch the 0G token balance for any wallet. This is your verify-connectivity call.
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)}
/>API Reference
Service health check. Returns current timestamp and API version. Useful for monitoring uptime.
curl https://pay.0g.ai/api/health