Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lib/Service/OpenAiAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ public function isUsingOpenAi(?string $serviceType = null): bool {
return $serviceUrl === '' || $serviceUrl === Application::OPENAI_API_BASE_URL;
}

/**
* @param ?string $serviceType
* @return bool
*/
public function isUsingOpenRouter(?string $serviceType = null): bool {
$serviceUrl = '';
if ($serviceType === Application::SERVICE_TYPE_IMAGE) {
$serviceUrl = $this->openAiSettingsService->getImageServiceUrl();
} elseif ($serviceType === Application::SERVICE_TYPE_STT) {
$serviceUrl = $this->openAiSettingsService->getSttServiceUrl();
} elseif ($serviceType === Application::SERVICE_TYPE_TTS) {
$serviceUrl = $this->openAiSettingsService->getTtsServiceUrl();
}
if ($serviceUrl === '') {
$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');
}

/**
* @param ?string $serviceType
*
Expand Down Expand Up @@ -221,7 +241,8 @@ public function getModels(?string $userId, bool $refresh = false, ?string $servi

try {
$this->logger->debug('Actually getting OpenAI models with a network request');
$modelsResponse = $this->request($userId, 'models', serviceType: $serviceType);
$params = $this->isUsingOpenRouter($serviceType) ? ['output_modalities' => 'all'] : [];
$modelsResponse = $this->request($userId, 'models', $params, serviceType: $serviceType);
} catch (Exception $e) {
$this->logger->warning('Error retrieving models (exc): ' . $e->getMessage());
throw $e;
Expand Down
Loading