diff --git a/lib/Service/OpenAiAPIService.php b/lib/Service/OpenAiAPIService.php index e96fb5a9..2b50cdc9 100644 --- a/lib/Service/OpenAiAPIService.php +++ b/lib/Service/OpenAiAPIService.php @@ -73,6 +73,15 @@ public function isUsingOpenAi(): bool { return $serviceUrl === '' || $serviceUrl === Application::OPENAI_API_BASE_URL; } + /** + * @return bool + */ + public function isUsingOpenRouter(): bool { + $serviceUrl = $this->openAiSettingsService->getServiceUrl(); + // Return true if the service URL references OpenRouter (e.g., openrouter.ai) + return str_starts_with(strtolower($serviceUrl), 'https://openrouter.ai'); + } + /** * @return string */ @@ -177,7 +186,8 @@ public function getModels(?string $userId, bool $refresh = false): array { try { $this->logger->debug('Actually getting OpenAI models with a network request'); - $modelsResponse = $this->request($userId, 'models'); + $params = $this->isUsingOpenRouter() ? ['output_modalities' => 'all'] : []; + $modelsResponse = $this->request($userId, 'models', $params); } catch (Exception $e) { $this->logger->warning('Error retrieving models (exc): ' . $e->getMessage()); throw $e;