Install
Works with Drupal: ^10.5 || ^11.2Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
Deprecated
----------
- Deprecate TokenEstimator::selectModel(). It has no caller anywhere in
this module — the two-tier model routing README.md advertised never ran.
Four of its five model_routing config keys (small_threshold,
large_model, small_label, large_label) drove nothing and are removed
by an update hook; small_model is kept, since computeDollarBudget()
still reads it as the pricing anchor for budget estimates. The method
itself is kept for one release as a no-op API deprecation and is removed
in 2.0.0 (#3615561).
Fixed
-----
- Remove the hardcoded extra.drupal version block from composer.json; it
claimed version 1.0.0 in every packaged release from 1.0.1 onwards
(#3615360).
- Enforce a shared monthly token ceiling for anonymous requests; they
previously bypassed quota enforcement entirely, so any AI feature
reachable without login (a public chatbot or search box) had no cost
ceiling. Anonymous traffic shares Drupal's reserved uid 0 and a
dedicated quota.anonymous_monthly_tokens setting (default 5000),
configured independently from per-authenticated-user quotas (#3616167).
- Record a streamed chat call exactly once instead of twice; both
PostGenerateResponseEvent and PostStreamingResponseEvent fired for the
same call, doubling recorded tokens/cost and consuming quota at twice the
real rate. An update hook merges historical duplicate rows created by this
defect, corrects any over-consumed quota for the current month, and
re-rolls any already-completed monthly rollup so past-month dashboards
stop serving the doubled totals too (#3615557).
- Stop double-charging cached tokens on OpenAI and Gemini; both report input
tokens inclusive of cache reads, so estimated cost billed the cached
portion once at the full input rate and again at the cache rate. Cost
calculation now subtracts cached tokens from input for providers in the
new quota.cache_inclusive_providers setting (default: openai, gemini);
stored token counts and quota consumption are unaffected — this only
corrects the displayed/recorded cost. An update hook recomputes
estimated_cost_usd for every historical row affected, from the raw
input/cached token counts already on record — no data is guessed or
estimated. Confirmed against a live OpenAI account: a real cache-hit call
(4095 input tokens, 3968 of them cached) now correctly records $0.00032025
instead of the $0.00091545 the previous code would have billed for the
same call (#3615553).
- Price cache-write (cache-creation) tokens; only cache-read tokens were
ever priced, understating cost on any prompt-caching site. Added
cache_write_per_token to the pricing source contract, mapped from
LiteLLM's cache_creation_input_token_cost and models.dev's
cost.cache_write. No caller currently supplies a non-zero count —
drupal/ai's TokenUsageDto has no field to read one from — tracked
separately upstream. Also corrected the cached_tokens Views help text,
which read as a blanket "reduces billable cost" claim once cache writes
(billed above input, currently invisible) are part of the picture
(#3615562).