apiKey property
String?
get
apiKey
Implementation
String? get apiKey {
if (_cachedApiKey != null) return _cachedApiKey;
final fromArgs = argResults?['api-key'] as String?;
if (fromArgs != null && fromArgs.isNotEmpty) {
_cachedApiKey = fromArgs;
return _cachedApiKey;
}
final fromEnv = Platform.environment['OPENAI_API_KEY'];
if (fromEnv != null && fromEnv.isNotEmpty) {
_cachedApiKey = fromEnv;
return _cachedApiKey;
}
final fromConfig = CommandsHelper.readApiKeyFromConfig();
if (fromConfig != null) {
_cachedApiKey = fromConfig;
return _cachedApiKey;
}
return null;
}