Feature: Load balanced API keys and voice registration responses for Company 1

This commit is contained in:
Hamza-Ayed
2026-05-22 23:09:38 +03:00
parent 9a2cf94b86
commit 2aa8862f77
6 changed files with 103 additions and 13 deletions

View File

@@ -108,12 +108,12 @@ class ChatbotController extends BaseController
// 4. Retrieve the Gemini API key (custom or system default)
$rules = ChatbotRule::findAllByCompany($request->company_id);
$apiKey = null;
$configuredKey = null;
if (!empty($rules) && !empty($rules[0]['gemini_api_key'])) {
$apiKey = $rules[0]['gemini_api_key'];
$configuredKey = $rules[0]['gemini_api_key'];
}
$apiKey = $apiKey ?: getenv('GEMINI_API_KEY');
$apiKey = \App\Services\GeminiService::getGeminiApiKey($configuredKey);
if (empty($apiKey)) {
$response->status(500)->json(['status' => 'error', 'message' => 'Gemini API Key is not configured in the system']);