| 1234567891011121314151617181920 |
- import Foundation
- enum OpenAIConfiguration {
- /// Emergency fallback key when plist/environment injection is unavailable.
- private static let fallbackAPIKey = "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"
- /// Read key from environment first, then Info.plist, then fallback.
- static var apiKey: String {
- let fromEnvironment = ProcessInfo.processInfo.environment["OPENAI_API_KEY"] ?? ""
- let fromPlist = Bundle.main.object(forInfoDictionaryKey: "OPENAI_API_KEY") as? String ?? ""
- let resolved = !fromEnvironment.isEmpty ? fromEnvironment : (!fromPlist.isEmpty ? fromPlist : fallbackAPIKey)
- return resolved.trimmingCharacters(in: .whitespacesAndNewlines)
- }
- /// Whether `apiKey` is currently populated with a real value.
- static var hasAPIKey: Bool {
- !apiKey.isEmpty
- }
- }
|