CNXT AI Cost Guardrails

Description

CNXT AI Cost Guardrails gives site administrators a local control plane for plugins that use the native WordPress AI Client.

The plugin records content-minimized operational metadata around native AI Client calls, estimates token-billed cost from rates you control, and can prevent later prompts after recorded monthly usage reaches a configured threshold.

Features

  • Sitewide monthly limits for estimated USD, AI call attempts, and total tokens.
  • Per-source monthly limits for plugins, mu-plugins, themes, core, and unknown callers.
  • Monitoring mode that marks calls which would have been prevented without blocking them.
  • Enforcement mode that uses the official pre-flight AI Client prevention filter.
  • Atomic request reservations to reduce concurrent overrun of request limits.
  • Conservative handling of missing token or price data.
  • Emergency stop that prevents new native AI Client prompts immediately.
  • Content-free audit rows for prompts blocked by configured limits, fail-closed safety checks, or the emergency stop.
  • Provider/model token-rate editor with historical estimate recalculation.
  • Usage by source, recent activity, retention controls, and formula-safe monthly CSV export.
  • No external service, account, telemetry, remote assets, license check, or paid feature lock.

All functionality included in this plugin is available without payment, registration, a license key, a quota, or a trial period.

Data minimization

CNXT AI Cost Guardrails stores only the time, inferred calling source, provider ID, model ID, capability, token counts, estimated cost, duration, coarse request context, and policy status.

It does not intentionally read or store prompt or response content, direct user identifiers, IP addresses, request URLs, API keys, or connector credentials. It briefly uses object identities, not message text, to correlate lifecycle events within one PHP request. All plugin data remains in the site’s own WordPress database. The plugin makes no outbound network requests and never starts an AI request.

Important limits

  • Coverage is limited to calls that pass through the native WordPress AI Client lifecycle. Direct provider SDK or HTTP calls are outside this plugin.
  • Enforcement and the emergency stop are designed for the recommended wp_ai_client_prompt() wrapper. Lower-level SDK calls may bypass the prevention filter.
  • If a provider result event never arrives, the plugin retains a content-free row with unknown token and cost values so request limits do not silently fail open.
  • The AI Client does not expose a caller ID. Source attribution is inferred from the synchronous PHP stack. Indirect calls may appear as core or unknown.
  • Enforcement reserves one request under a MySQL or MariaDB lock before generation. A single call can still exceed a token or USD threshold.
  • When token or price information is missing, enforcement is conservative. A configured request limit can serve as the measurable fallback.
  • USD values are estimates, not invoices. Cached input, batch pricing, media pricing, free tiers, discounts, taxes, and provider-specific rules may differ.
  • Keep provider-side billing caps enabled as the final backstop.

Privacy

The plugin stores content-minimized operational metadata locally for site administrators and does not contact a third party. Operational timestamps and source/context labels may still be sensitive in some environments, so site owners should choose an appropriate retention period. Site owners should also evaluate their AI providers and the plugins initiating AI requests, because those components may process content under separate terms.

Upgrading from a previous slug

Deactivate the previous version before activating CNXT AI Cost Guardrails. Do not run both versions at the same time. Activation migrates existing local settings and renames the legacy events table for each site as that site loads. Existing limits, emergency-stop state, token rates, and usage history are retained. If legacy storage cannot be migrated safely, native AI Client prompts are paused and an administrator notice is displayed until initialization succeeds.

Custom integrations must use the new cnxt_aicg_ filter prefix and CNXTAICostGuardrails namespace.

Installation

  1. In WordPress Admin, go to Plugins > Add New > Upload Plugin.
  2. Select the plugin ZIP and activate CNXT AI Cost Guardrails.
  3. Open CNXT AI Cost Guardrails in the WordPress Admin menu.
  4. Leave Monitoring mode enabled while you observe normal usage.
  5. Add current per-model token rates under Token rates if you want USD estimates or USD enforcement.
  6. Configure sitewide and per-source limits, then switch to Enforcing when ready.

WordPress 7.0 or later is required. At least one AI provider connector must be configured before other plugins can make native AI Client calls, but this plugin remains safe to activate without a provider.

FAQ

Does this plugin send data to an external server?

No. It contains no telemetry and makes no outbound requests. All settings and events remain in the local WordPress database.

Does it require payment, registration, or a license key?

No. Every function included in the plugin is available immediately and has no trial period or built-in usage quota.

Does it store prompts or AI responses?

No. The plugin intentionally does not inspect message content. Prompt and response content is never stored or exported.

Why is estimated cost marked incomplete?

WordPress AI Client returns token usage but not price. Add a current input and output rate for each token-billed provider/model pair. Calls with no matching rate remain unpriced rather than being treated as free.

Do request and token limits work without token rates?

Yes. Request and token limits use native usage counters and do not depend on pricing. USD limits need a complete rate table for ordinary estimate-based enforcement; unknown price data is handled conservatively.

Is this a guaranteed provider billing cap?

No. Native calls reserve a request slot atomically before generation, but final token size and estimated cost are unavailable until a result returns. One call can exceed a threshold, and direct API calls bypass the WordPress filter. Use the provider’s billing controls as the authoritative cap.

What is Monitoring mode?

Monitoring mode records AI call attempts and marks completed calls made after usage had already reached a configured sitewide or source limit, without blocking them. Review those results before enabling Enforcement mode.

What does the emergency stop cover?

It immediately returns a prevention decision through the official WordPress AI Client filter. It cannot stop plugins that bypass the WordPress wrapper and call a provider directly.

Can I export or remove the data?

Yes. Tools & privacy includes a formula-safe monthly CSV export and a button to delete all event history. You can also opt in to full data removal when the plugin is uninstalled. Deactivation alone never deletes data.

Does it support multisite?

Each site maintains its own table, settings, rates, and limits. A network-activated installation initializes each site lazily when that site’s plugin runtime loads. There is no network-wide aggregate dashboard in version 1.5.1.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“CNXT AI Cost Guardrails” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.5.1

  • Aligned the display name, plugin directory, main file, and text domain with cnxt-ai-cost-guardrails.
  • Updated PHP namespaces and constants, action/filter names, nonces, storage keys, asset identifiers, and CSV filenames to the new prefixes.
  • Added a guarded migration for settings and usage history from the previous slug.

1.5.0

  • Renamed the plugin and text domain to AI Cost Guardrails-CNXT.
  • Enabled sitewide and per-source USD, request, and token limits for every user.
  • Made every included control available without payment or a license key and removed external sales links.
  • Retained atomic request reservations, fail-closed database handling, local reporting, CSV export, and privacy controls.