Guide updated
Implemented; real-account verification is pending. The public balance endpoint does not specify units. We currently convert cents to USD following Cloudflare's official reference implementation; verify both the amount and units against your console on first use.
- Required credentials
- Cloudflare API Token
- Monitoring currency
- USD · US dollars
- What is monitored
- Account AI Gateway Credits
- The selected Cloudflare account's shared AI Gateway Unified Billing credits. This is not a separate Gateway, API key, or Quota Monitor project wallet, and not the account balance for all Cloudflare products.
How to check Cloudflare AI Gateway credits manually
- Sign in to Cloudflare Dashboard and select the account you actually use.
- Open AI → AI Gateway and read Credits Available (USD) at the top right.
- Select Manage to inspect top-up settings or add credits. Do not confuse this wallet with BYOK provider funds or invoices for other Cloudflare products.
Connect Cloudflare AI Gateway to Quota Monitor
1. Confirm your account and Unified Billing wallet
Sign in to Cloudflare Dashboard, select the account running your AI Gateway, and open AI → AI Gateway. Find Credits Available at the top right. If you have several accounts, check the account name first. BYOK-only traffic or separately billed Workers AI does not imply this wallet has funds.
Check: this account's AI Gateway Credits are what you want to monitor. You do not need to top up or change a production Gateway's billing mode just to connect monitoring.
2. Copy the Account ID
With the correct account selected, press Ctrl+K / Cmd+K to open Dashboard search, enter Copy account ID, and copy the ID. You can also find Account ID under Workers & Pages → Account details.
Check: it is the 32-character hexadecimal Account ID, not a Zone ID, Gateway ID, account name, or URL. Do not put it in a provider project ID field.
3. Create a dedicated custom API Token
Open your avatar → My Profile → API Tokens → Create Token. Under Custom token, select Get started and name it Quota Monitor AI Gateway. Create a separate token; do not alter an existing production token.
Check: you are creating an API Token, not revealing a Global API Key or creating a model-calling AI Gateway Run token.
4. Grant read access to one account
Under Permissions, select Account → AI Gateway → Read. Under Account Resources, select Include → Specific account and choose the account from step 1. Remove unrelated permission rows. Do not select All accounts, Write/Edit, or Run.
Check: only the intended account's AI Gateway Read permission is granted. It also authorizes other AI Gateway reads; it is not a balance-only permission. Quota Monitor calls only the balance endpoint. If the account or permission is unavailable, ask an administrator rather than granting broader access.
5. Review restrictions and save the complete Token
Set an expiry according to your team's policy. If you use Client IP Address Filtering, allow Quota Monitor's actual server egress IP, not your browser's IP. If unknown, ask your administrator; do not bypass an existing IP policy. Click Continue to summary, review the account and permissions, and click Create Token.
The full Token is normally shown once. Save it securely. Check: you copied the secret Token value, not the Token ID, without a Bearer prefix. Never put it in chat, screenshots, or MCP parameters.
6. Save the connection inside your project
In Quota Monitor, open the target project → add provider connection → add new connection. Choose Cloudflare AI Gateway (USD Credits). Enter a recognizable connection name, the Account ID from step 2, and the API Token from step 5. Save and connect to the project.
Both sensitive fields are masked and encrypted together; lists show only the Token's last four characters. No API URL, Gateway ID, or provider project ID is required. For MCP setup, enter these fields through the secure setup link instead of sending the Token to an agent.
7. Sync and reconcile the amount
Wait for first sync or select Query latest balance. Confirm a new successful query time, then compare the USD amount with Credits Available in the same Cloudflare account's AI Gateway. Do not compare the total Cloudflare invoice, Workers AI usage, or a BYOK provider wallet.
Check: account, currency, units, and time match. Real-account acceptance is still pending; specifically check for a 100× unit difference. If anything differs, share only error codes, query times, and redacted amounts, never the Token. An old snapshot after failure is not a fresh balance.
8. Top up on Cloudflare when needed
Select Open provider on the card, then the same account → AI Gateway → Credits Available → Manage → Top-up credits. Review Cloudflare's current charges and complete payment yourself.
Check: payment has settled before syncing again. Quota Monitor does not top up, change auto-reload or payment methods, or store card details returned by the endpoint.
9. Replace or revoke safely
Create another dedicated read-only Token using steps 3–5, then add a replacement connection with its Account ID and Token. Verify sync, remove the old connection from every project using it, delete the now-unused connection in connection management, and revoke its Token in Cloudflare. If your plan has no spare connection slot, plan a replacement window first; do not revoke production credentials merely to test.
Check: you did not revoke another application's production credentials. Removing a connection from one project does not automatically revoke its Cloudflare Token. Revoke an unused dedicated Token yourself when you stop monitoring.
What Quota Monitor reads from Cloudflare AI Gateway
- Only AI Gateway Credits used through Unified Billing are included. BYOK charges are paid directly to the provider, whose balance is excluded. Workers AI draws from these credits only when routed through a Gateway using Unified Billing; other billing paths are excluded.
- Gateways, keys, and Quota Monitor projects may share the same account credits. Do not add duplicate balances together. Zero or negative credits alone cannot determine whether BYOK or other billing modes still work.
- This is the most recent successful query, not a promise of immediate upstream settlement. Negative amounts are preserved. Failed queries never become zero or an estimate derived from payments or usage.
- The cents unit follows Cloudflare's official cloudflare-os implementation of the older endpoint. Units for the new public path and live-account reconciliation still need verification. Compare with Credits Available on first use; if amounts differ by 100×, stop relying on that amount and report it rather than changing a conversion rate.
- The dashboard shows the latest successful snapshot. Manual refresh queries the provider again but cannot eliminate upstream billing delays. An old balance is not a new result after a failed query.
Cloudflare AI Gateway FAQ and troubleshooting
- Why do I get 401, 403, or a rejected sync?
- Check the complete Token, expiry/revocation, matching Account ID, AI Gateway Read permission for that account, and server IP restrictions. Successful model calls do not prove balance access. Do not troubleshoot by switching to a Global API Key, Cookie, or all-account permissions.
- Why are credits zero, negative, or different from other Cloudflare charges?
- This wallet contains only Unified Billing credits. BYOK and separately billed Workers AI are excluded. Cloudflare can report negative outstanding credits, which are preserved. Reconcile Credits Available in the same account, not the amount you paid to buy credits.
- Why does the amount appear 100 times too large or small?
- The new public endpoint does not specify units. We currently divide cents by 100 following Cloudflare's official older-path example, pending live-account verification. Stop relying on that amount for funding decisions and report query time plus redacted console amounts. We do not guess units from the magnitude or substitute estimated balances.
- Why do several projects show the same credits?
- AI Gateways in one Account ID share account-level credits. Quota Monitor projects group your business activity; they do not create separate Cloudflare wallets. Do not sum the same funds repeatedly.
- Why did a top-up not appear, or why did sync fail?
- Confirm payment settlement and the account, then inspect the last successful sync time. Retry later after a 429. Unavailable endpoints or unexpected responses fail explicitly instead of becoming zero. Refreshing cannot accelerate Cloudflare settlement; never disclose the Token to troubleshoot.
Official Cloudflare AI Gateway references
- Official reference · developers.cloudflare.com/api/resources/ai_gateway/subresources/billing/methods/credit_balance/(opens in a new tab)
- Official reference · developers.cloudflare.com/ai-gateway/features/unified-billing/(opens in a new tab)
- Official reference · developers.cloudflare.com/fundamentals/api/get-started/create-token/(opens in a new tab)
- Official reference · developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/(opens in a new tab)
- Official reference · github.com/cloudflare/cloudflare-os/blob/main/packages/workshop-backend/src/ai-gateway-billing/cloudflare/account-service.ts(opens in a new tab)
Prepared by Quota Monitor, not an official provider tutorial. Interfaces and permissions may change; check official pages. Verification is limited to the scope stated here.