The shared Forge Credits widget exposes two entry points any plugin admin script can use:
js
// Force a fresh admin-ajax pull of the balance and re-render the chip + dropdown.
// Used after an AI action — the PHP forge-api client has already stashed the
// updated balance in the transient via Forge_Credits_Widget::push_credits().
window.ForgeCredits.refresh();
// Same as refresh() but via DOM event — useful when you don't have a direct
// reference to window.ForgeCredits (e.g. in a cross-plugin script).
document.dispatchEvent(new CustomEvent('forge:credits-refresh'));
// If your AJAX response already carries a credits payload, you can apply it
// directly without a round-trip:
window.ForgeCredits.applyInfo({
total: 10000, used: 4200, remaining: 5800, bonus: 0, resets_at: '2026-05-01'
});SEO Forge’s admin.js wires a global $(document).ajaxSuccess hook that fires ForgeCredits.refresh() whenever a call to a credits-spending REST path completes. See SF_CREDITED_PATH in assets/js/admin.js for the path regex.
—