Skip to content

AI Effort

One reasoning effort level for every AI provider. Each vendor names its reasoning control differently: Anthropic output_config.effort, OpenAI and OpenRouter reasoning_effort / reasoning.effort, Gemini thinkingConfig.thinkingLevel. This module gives consumers one scale and one way to ask, and translates the level for each provider.

Scale

none, minimal, low, medium, high, xhigh, max. Each model accepts a subset.

Consumer API

use Drupal\ai_effort\EffortManager;

// What to offer: the model's levels, up to the site's ceiling, or NULL.
$levels = \Drupal::service(EffortManager::class)->levels('openrouter', 'openai/gpt-5-mini');
// $levels->levels: ['minimal', 'low', 'medium', 'high']; $levels->default: 'medium'.

// What to send: request metadata on the input.
$input->setRequestMetadataValue(EffortManager::METADATA_KEY, 'high');
  • No level: the provider's default.
  • A level the model doesn't offer, or above the site's ceiling: dropped and logged in the ai_effort channel, never sent.
  • Metadata does nothing when this module isn't installed, so consumers can set it without depending on the module.
  • When the request has no output limit, the module sets one for medium and above (4096 to 16384 tokens), because reasoning counts against it.

Providers

Provider Levels from Sent as
OpenRouter /models reasoning.supported_efforts, cached for a day reasoning.effort
Gemini (3.x) Table in the adapter thinkingConfig (ThinkingConfig object)
Cloudflare AI Gateway Table: Workers AI gpt-oss, Google AI Studio Gemini 3.x reasoning_effort
Any provider with its own effort or reasoning_effort select, e.g. Anthropic 1.3, OpenAI The provider's select options That key

Anthropic Provider 1.2.x calls Anthropic's OpenAI-compatible endpoint, which ignores effort; use 1.3.

Adapters are EffortAdapter plugins (src/Plugin/EffortAdapter). An adapter names the provider IDs it handles and, optionally, a module it needs.

Settings

/admin/config/ai/effort: the highest level requests may use. Needs the "administer ai" permission.

Manual check

scripts/try.php sends one question at several levels through real providers and prints the reasoning tokens. On a site with the providers configured:

drush php:script web/modules/custom/ai_effort/scripts/try.php
  • AI #3586787: a provider-agnostic reasoning effort control in AI core. This module would retire once core has it.
  • AI #3586788: streamed chat from OpenAI-type providers reports 0 reasoning and cached tokens.
  • AI #3586789: PostStreamingResponseEvent has an empty configuration.
  • OpenRouter Provider #3627909: the provider's own Reasoning Effort setting is never offered.
  • Anthropic Provider #3607963: 1.3.0-beta2 drops tool calls from streamed responses. Merge request: !37.

Maintainers

  • Tyler Brown Cifu Shuster - tbcs

This project has been sponsored by: