ApiKeys
Wisej.AI.Helpers.ApiKeys
Namespace: Wisej.AI.Helpers
Assembly: Wisej.AI (3.5.0.0)
Provides methods to retrieve API keys from environment variables or a configuration file.
public class ApiKeys
Methods
GetApiKey(name, namePostfix, envPrefix)

Retrieves the API key associated with the specified name.
Returns: String. The API key if found; otherwise, null
.
This method first attempts to retrieve the API key from environment variables using the specified prefix. If not found, it attempts to read the key from a JSON configuration file located at the path defined by AI_PATH
and APIKEYS_FILENAME
.
string apiKey = ApiKeys.GetApiKey("MyService", "Postfix");
if (apiKey != null)
{
// Use the API key
}
Last updated