Step 1: Create a TimeGPT account and generate your API key
- Go to dashboard.nixtla.io
- Sign in with Google, GitHub or your email
- Create your API key by going to โAPI Keysโ in the menu and clicking on โCreate New API Keyโ
- Your new key will appear. Copy the API key using the button on the right.

Step 2: Install Nixtla
In your favorite Python development environment: Installnixtla
with pip
:
Step 3: Import the Nixtla TimeGPT client
NixtlaClient
class providing your authentication API key.
validate_api_key
method.
Step 4: Start making forecasts!
Now you can start making forecasts! Letโs import an example using the classicAirPassengers
dataset. This dataset contains the monthly
number of airline passengers in Australia between 1949 and 1960. First,
load the dataset and plot it:
timestamp | value |
---|---|
date | i64 |
1949-01-01 | 112 |
1949-02-01 | 118 |
1949-03-01 | 132 |
1949-04-01 | 129 |
1949-05-01 | 121 |

๐ Data RequirementsFor further details go to Data Requeriments.
- Make sure the target variable column does not have missing or non-numeric values.
- Do not include gaps/jumps in the timestamps (for the given frequency) between the first and late timestamps. The forecast function will not impute missing dates.
- The time column should be of type Date or Datetime.
Forecast a longer horizon into the future
Next, forecast the next 12 months using the SDKforecast
method. Set
the following parameters:
df
: A pandas DataFrame containing the time series data.h
: Horizons is the number of steps ahead to forecast.freq
: The polars offset alias, see the possible values here.time_col
: The column that identifies the datestamp.target_col
: The variable to forecast.
timestamp | TimeGPT |
---|---|
date | f64 |
1961-01-01 | 437.837921 |
1961-02-01 | 426.062714 |
1961-03-01 | 463.116547 |
1961-04-01 | 478.244507 |
1961-05-01 | 505.646484 |

timegpt-1-long-horizon
model. Use this
model if you want to predict more than one seasonal period of your data.
For example, letโs forecast the next 36 months:
timestamp | TimeGPT |
---|---|
date | f64 |
1961-01-01 | 436.843414 |
1961-02-01 | 419.351532 |
1961-03-01 | 458.943146 |
1961-04-01 | 477.876068 |
1961-05-01 | 505.656921 |

Produce a shorter forecast
You can also produce a shorter forecast. For this, we recommend using the default model,timegpt-1
.
