APIKeyManager
A singleton class responsible for managing API keys used by the application.
Declaration
final class APIKeyManager
Overview
The APIKeyManager
class provides a centralized place to store and retrieve various API keys required by the application. It supports loading API keys from environment variables and manually setting them in code.
Ensure that you securely store and manage your API keys. Avoid committing API keys to version control systems or distributing them with your application.
Setting the keys
An example of how to use the APIKeyManager
to retrieve and set API keys.
To set the API keys using Xcode environment variables, follow these steps:
- In Xcode, select your project in the Project Navigator.
- Select your target, then click the “Info” tab.
- Under the “Configurations” section, click the “+” button in the bottom-left corner.
- In the newly added row, set the “Name” to the desired API key name (e.g., “TEAM_API_KEY”) and the “Value” to your API key.
- Repeat step 4 for each API key you need to set.
With the environment variables set, the APIKeyManager
will automatically load and use the API keys from the corresponding environment variables.
You can also set the API keys directly in code if needed:
AiXplainKit.shared.keyManager.TEAM_API_KEY = "<Your Key>"
Topics
Instance Properties
The base URL for the backend API.
The API token for Hugging Face (optional).
The URL for the models run API endpoint.
Instance Methods
Clean all keys provided
Type Properties
static var shared: APIKeyManager
The shared instance of the APIKeyManager.