diff --git a/src/Service/GeminiAiService.php b/src/Service/GeminiAiService.php
index 0a5fdf5a9fd1d25552030699c79be6f6470a9129..8e265558b637f214df23aaccda865aa22eeb63c1 100644
--- a/src/Service/GeminiAiService.php
+++ b/src/Service/GeminiAiService.php
@@ -36,14 +36,18 @@ class GeminiAiService {
   public function __construct(ConfigFactoryInterface $configFactory) {
     $this->configFactory = $configFactory;
     
-    // Retrieve the configuration for the module
+    // Retrieve the configuration for the module.
     $config = $configFactory->get('aidmi.settings');
+    // Get the input method.
+    $apiInputMethod = $config->get('api_input_method');
 
     // Initialize the API key variable.
     $apiKey = '';
 
     // Check if the API key is to be retrieved from the file.
     if ($apiInputMethod === 'file_path') {
+      // Get the API key file path from the configuration.
+      $apiKeyFilePath = $config->get('api_key_file_path');
       $siteRoot = \Drupal::root(); // Get the site root.
       $fullFilePath = $siteRoot . '/' . ltrim($apiKeyFilePath, '/'); // Full file path.
       // Check if the file exists and is readable.