Problem/Motivation

OpenRouterProvider::getModelSettings() adds a reasoning_effort select for reasoning models. But OpenRouterProvider::getAvailableConfiguration() overrides the base method. It returns only dimensions for embeddings and [] for chat, and it never calls getModelSettings(). As a result, the effort setting never appears in provider configuration forms, never gets a default, and is hidden from consumers that read getAvailableConfiguration('chat', $model).

Steps to reproduce

drush ev 'print_r(\Drupal::service("ai.provider")->createInstance("openrouter")->getAvailableConfiguration("chat", "openai/gpt-5-mini"));'

This prints an empty array.

Proposed resolution

  1. In getAvailableConfiguration(), return $this->getModelSettings($model_id, $general) for chat, as #3604211: Embeddings operation ignores provider configuration (dimensions parameter not passed) did for embeddings.
  2. Replace the hard-coded id prefixes in isReasoningModel() with /models metadata. Each reasoning model has reasoning.supported_efforts and reasoning.default_effort. As of 2026-10-02, 332 of 466 models have them. Build the options from supported_efforts. This covers Claude, Gemini, Grok, DeepSeek and others, not only openai/gpt-5*, o1 and o3.
  3. Send reasoning: {effort: …}, which is OpenRouter's documented shape. Top-level reasoning_effort is also accepted. Both are validated, and an invalid value returns 400.
  4. Cache OpenRouterClient::listModels(). Right now it calls /models and /embeddings/models on every getConfiguredModels(), getMaxInputTokens() and getMaxOutputTokens() call.

Also found

  • OpenRouterStreamedChatMessageIterator.php:35-36 reads completionTokenDetails, but the SDK property is completionTokensDetails. Because of this, streamed reasoning and cached token usage is always 0.
  • OpenRouterClient builds the openai-php client without withHttpClient(), so ai.settings:request_timeout is not applied.

Remaining tasks

  • MR
  • Tests
  • Review

User interface changes

A reasoning effort select appears in chat provider configuration for models that support it.

API changes

getAvailableConfiguration('chat', $model_id) returns model settings instead of an empty array.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tbcs created an issue. See original summary.

tbcs’s picture

Assigned: Unassigned » tbcs
Status: Active » Needs review

  • bdsweb committed a40e44a0 on 1.1.x
    Issue #3627909 by tbcs, bdsweb: Offer the reasoning effort setting for...
bdsweb’s picture

Assigned: tbcs » bdsweb
Status: Needs review » Fixed

Committed to 1.1.x and tagged 1.1.7.

The select stores effort ids (minimal, low, medium, high), which is what the AI configuration element submits. MR !7 targets 1.0.x, so it was not merged. This release also corrects streamed reasoning and cached token usage, and applies the AI request timeout.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

bdsweb’s picture

Status: Fixed » Closed (fixed)