diff --git a/enterprise/app/models/enterprise/concerns/article.rb b/enterprise/app/models/enterprise/concerns/article.rb index 4527bfdf6..8392d620c 100644 --- a/enterprise/app/models/enterprise/concerns/article.rb +++ b/enterprise/app/models/enterprise/concerns/article.rb @@ -65,7 +65,8 @@ module Enterprise::Concerns::Article { role: 'system', content: article_to_search_terms_prompt }, { role: 'user', content: "title: #{title} \n description: #{description} \n content: #{content}" } ] - headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY', nil)}" } + headers = { 'Content-Type' => 'application/json', + 'Authorization' => "Bearer #{InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_API_KEY')&.value}" } body = { model: 'gpt-4o', messages: messages, response_format: { type: 'json_object' } }.to_json Rails.logger.info "Requesting Chat GPT with body: #{body}" response = HTTParty.post(openai_api_url, headers: headers, body: body)