Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: Video.js (HTML5 Video Player) 10.0.0-alpha1 First alpha version released for module videojs (10.0.0-alpha1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

AI Metering

48 sites Security covered Drupal 10–11 AI ecosystem
View on drupal.org

This module tracks AI token usage, estimates costs, and allows setting per-user monthly quotas. It automatically records every AI call the system makes, providing a dashboard for usage overviews and a detailed log for auditing.

AI Metering adds token usage tracking, cost estimation, per-user monthly quotas, and two usage dashboards to any Drupal site running the AI module. It subscribes to drupal/ai's event system and records every AI call automatically: any provider registered with the AI module is covered, with no per-provider configuration.

Features

  • Automatic call interception: every provider registered with the AI module is tracked, with zero per-provider configuration.
  • Per-user monthly quotas with pre-flight checks: over-budget calls are rerouted to a local fallback provider (e.g. Ollama) at zero cost, or blocked before the remote API is contacted.
  • Cost tracking in USD, displayed in USD, CAD, EUR, GBP, AUD, or JPY with live exchange rates.
  • Pluggable pricing sources (LiteLLM cost map, models.dev); manual overrides survive every sync.
  • Dashboard by User and Dashboard by Role, with CSV and JSON export.
  • Per-call usage log: tokens, latency, calling feature, and cost at 8-decimal precision; filterable and exportable.
  • Pluggable alert channels: email and webhook (Slack/Teams-compatible) ship built in.
  • Personal usage self-service: a block and a profile tab let editors see their own monthly usage and quota.
  • Monthly rollup and retention purge, without losing historical dashboard totals.
  • GDPR-aware data lifecycle: usage purged on account deletion, reassigned to anonymous on cancellation.
  • Context grouping, hooks and events for grouping agent runs and extending the module.

Getting started

Enable the module, then go to Admin → Configuration → AI → AI Metering (/admin/config/ai/ai-metering). The documentation site covers installation, permissions, configuration, both dashboards, Drush commands, and the hooks API.

Additional Requirements

  • Drupal 10.5+ or 11.2+
  • PHP 8.2+ (8.3+ on Drupal 11)
  • AI module (drupal/ai)
  • At least one AI provider module (e.g. ai_provider_anthropic, ai_provider_openai, or any community provider)
  • Key module: used by the Anthropic token-counting adapter when available.
  • Ollama provider: a zero-cost local fallback for quota-exhausted calls.
  • LiteLLM proxy (optional): proxy-level spend reports via Drush.

Similar projects

Two other contrib modules address AI usage governance:

  • AI Usage Limits: per-provider token limits with hard blocking.
  • AI Budget Control: declarative limit rules, scopes, sliding time windows, and anti-flood protection.

AI Metering overlaps with both on core metering, and is closest in scope to AI Budget Control. The main differences are cost transparency across providers (pricing from a 100+ model cost map, multi-currency), a graceful local-model fallback instead of a hard block, and a per-user dashboard backed by a full per-call audit trail. There is an active conversation about consolidating this overlapping functionality: #3595756.

Supporting this Module

Use the issue queue for bug reports and feature requests. When filing a bug, include your Drupal and module versions and any relevant output from drush watchdog:show --type=ai_metering.

Built by a human using an AI assistant: 🤖 ➕ 🧠

Note that extensive parts of this module were generated via AI coding agents under human supervision.

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Jun 2026
Latest release
2 weeks ago
Releases (12 mo)
6 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.2 Stable 10–11 Aug 14, 2026
1.0.1 Stable 10–11 Aug 7, 2026
1.0.x-dev Dev 10–11 Aug 4, 2026
1.0.0 Stable 10–11 Aug 3, 2026
1.0.0-beta1 Pre-release 10–11 Jun 22, 2026
1.0.0-alpha1 Pre-release 10–11 Jun 2, 2026