httpClientFromApiKey function
Client
httpClientFromApiKey(
- String? apiKey
)
Implementation
http.Client httpClientFromApiKey(String? apiKey) {
apiKey ??= _apiKeyEnvVars.map(getConfigVar).nonNulls.firstOrNull;
var headers = {
'X-Goog-Api-Client':
'genkit-dart/$genkitVersion gl-dart/${getPlatformLanguageVersion()}',
'x-goog-api-key': ?apiKey,
};
if (apiKey == null) {
throw GenkitException(
'apiKey must be set to an API key',
status: StatusCodes.INVALID_ARGUMENT,
);
}
final baseClient = CustomClient(defaultHeaders: headers);
return baseClient;
}