OpenAiClient constructor
OpenAiClient({})
Implementation
OpenAiClient({String? apiUrl, String? apiKey, String? model, super.delay, super.logger})
: _dio = Dio(),
_model = model ?? 'gpt-4.1',
_apiUrl = apiUrl ?? 'https://api.openai.com/v1',
_apiKey = apiKey ?? Platform.environment['OPENAI_API_KEY'] ?? '' {
if (_apiKey.isEmpty) {
throw Exception('OPENAI_API_KEY not found in environment variables.');
}
_dio.options.baseUrl = _apiUrl;
_dio.options.headers['Authorization'] = 'Bearer $_apiKey';
_dio.options.headers['Content-Type'] = 'application/json';
}