Skip to main content

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:

  1. In Xcode, select your project in the Project Navigator.
  2. Select your target, then click the “Info” tab.
  3. Under the “Configurations” section, click the “+” button in the bottom-left corner.
  4. 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.
  5. 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

var AIXPLAIN_API_KEY: String?

var BACKEND_URL: URL?

The base URL for the backend API.

var HF_TOKEN: String?

The API token for Hugging Face (optional).

var MODELS_RUN_URL: URL?

The URL for the models run API endpoint.

var MODEL_API_KEY: String?

var PIPELINE_API_KEY: String?

var TEAM_API_KEY: String?

Instance Methods

func clear()

Clean all keys provided

Type Properties

static var shared: APIKeyManager

The shared instance of the APIKeyManager.