Api Key go to your
Dashboard.
There are different ways to set up your API key. We provide some
examples below. A scematic is given below.
1. Copy and paste your key directly into your Python code
This approach is straightforward and best for quick tests or scripts that wonβt be shared.- Step 1: Copy the API key found in the
API Keysof your Nixtla dashboard. - Step 2: Paste the key directly into your Python code, by
instantiating the
NixtlaClientwith your API key:
Important This approach is considered unsecure, as your API key will be part of your source code.
2. Secure: using an environment variable
- Step 1: Store your API key in an environment variable named
NIXTLA_API_KEY. This can be done (a) temporarily for a session or (b) permanently, depending on your preference. - Step 2: When you instantiate the
NixtlaClientclass, the SDK will automatically look for theNIXTLA_API_KEYenvironment variable and use it to authenticate your requests.
Important
The environment variable must be named exactly NIXTLA_API_KEY, with
all capital letters and no deviations in spelling, for the SDK to
recognize it.
a. Temporary: From the Terminal
This approach is useful if you are working from a terminal, and need a temporary solution.Linux / Mac
Open a terminal and use theexport command to set NIXTLA_API_KEY.
Windows
For Windows users, open a Powershell window and use theSet command to
set NIXTLA_API_KEY.
b. Permanent: Using a .env file
For a more persistent solution place your API key in a .env file
located in the folder of your Python script. In this file, include the
following:
dotenv package to load the .env file and then instantiate the
NIXTLA_API_KEY class. For example:
Important Remember, your API key is like a password - keep it secret, keep it safe!
3. Validate your API key
You can always find your API key in theAPI Keys section of your
dashboard. To check the status of your API key, use the
validate_api_key method of the
NixtlaClient
class. This method will return True if the API key is valid and
False otherwise.
TimeGPT.
This function is provided for your convenience to ensure its validity.
For full access to TimeGPTβs functionalities, in addition to a valid
API key, you also need sufficient credits in your account. You can check
your credits in the Usage section of your
dashboard.
