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
- In
getAvailableConfiguration(), return$this->getModelSettings($model_id, $general)forchat, as #3604211: Embeddings operation ignores provider configuration (dimensions parameter not passed) did for embeddings. - Replace the hard-coded id prefixes in
isReasoningModel()with/modelsmetadata. Each reasoning model hasreasoning.supported_effortsandreasoning.default_effort. As of 2026-10-02, 332 of 466 models have them. Build the options fromsupported_efforts. This covers Claude, Gemini, Grok, DeepSeek and others, not onlyopenai/gpt-5*,o1ando3. - Send
reasoning: {effort: …}, which is OpenRouter's documented shape. Top-levelreasoning_effortis also accepted. Both are validated, and an invalid value returns 400. - Cache
OpenRouterClient::listModels(). Right now it calls/modelsand/embeddings/modelson everygetConfiguredModels(),getMaxInputTokens()andgetMaxOutputTokens()call.
Also found
OpenRouterStreamedChatMessageIterator.php:35-36readscompletionTokenDetails, but the SDK property iscompletionTokensDetails. Because of this, streamed reasoning and cached token usage is always 0.OpenRouterClientbuilds the openai-php client withoutwithHttpClient(), soai.settings:request_timeoutis 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.
Issue fork ai_provider_openrouter-3627909
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
Comment #3
tbcs commentedComment #5
bdsweb commentedCommitted 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.
Comment #7
bdsweb commented