Issue #3609168 by codeitwisely: Let local OpenAI-compatible endpoints be recorded as local
Closes https://www.drupal.org/project/ai_metering/issues/3609168
What changed
provider_type was decided from a hardcoded provider-id whitelist, so a local model served over an OpenAI-compatible endpoint (provider id openai pointed at Ollama or LM Studio) was recorded as cloud, wrongly consuming the cloud quota and showing under cloud cost.
- New local_provider_ids setting (list) extends the built-in local providers. resolveProviderType() records a call as local when its provider id is in the built-in list or the configured list.
- Settings form field "Additional local provider IDs" (one per line), under Quota defaults.
- hook_update_9021 adds the key on existing installs.
Testing steps
- Point ai_provider_openai at a local Ollama OpenAI-compatible endpoint.
- In AI Metering settings, add openai to "Additional local provider IDs", save.
- Run a call through it: the usage log records provider_type = local (no cloud cost, no cloud quota).
Verified live (Drupal 11.3, ai_provider_openai pointed at local Ollama): before, openai recorded as cloud; after adding it to the setting, recorded as local. Two kernel tests (default cloud, configured local). Suite green (159 tests, 588 assertions), PHPCS and PHPStan clean.
AI assistance
Found through live multi-provider testing; fix with AI assistance.
Edited by Jérôme Tchania