Quickstart
Learn how to use TimeGPT for accurate time series forecasting in just a few steps
TimeGPT is a production-ready generative pretrained transformer for time series. It can accurately predict domains such as retail, electricity, finance, and IoT with just a few lines of code. Get started below!
Implementation Guide
Create a TimeGPT account and generate your API key
• Visit dashboard.nixtla.io to activate your free trial and create an account.
• Sign in using Google, GitHub, or your email.
• Navigate to API Keys in the menu and select Create New API Key.
• Your new API key will appear on the screen. Copy this key using the button on the right.
Dashboard displaying TimeGPT API keys and controls.
Install Nixtla
Install the Nixtla library in your preferred Python environment:
Import the Nixtla TimeGPT client
Import the Nixtla client and instantiate it with your API key:
Verify the status and validity of your API key:
API Validation Output
API Validation Output
Important: For enhanced security practices, see our guide on Setting Up your API Key.
Start making forecasts!
1. Load the AirPassengers Dataset
We will use the classic AirPassengers
dataset to demonstrate forecasts.
2. Preview the Dataset
Quickly examine structures like timestamps and values before forecasting.
3. Plot the Time Series
Visualize historical data to understand trends or seasonality.
timestamp | value | |
---|---|---|
0 | 1949-01-01 | 112 |
1 | 1949-02-01 | 118 |
2 | 1949-03-01 | 132 |
3 | 1949-04-01 | 129 |
4 | 1949-05-01 | 121 |
Plot the dataset:
Historical AirPassengers data from 1949 to 1960.
Data Requirements
Data Requirements
- The target variable must not contain missing or non-numeric values.
- Date stamps must form a continuous sequence without gaps for the selected frequency.
- Pandas should correctly parse the timestamp column (see Pandas documentation).
- The forecast method does not fill or handle missing dates.
For more details, visit Data Requirements.
Saving Figures from TimeGPT
Saving Figures from TimeGPT
The plot
method automatically displays figures in notebook environments. To save a plot locally:
Short and Long-Term Forecasting Examples
Generate a longer-term forecast
Generate a longer-term forecast
Forecast the next 12 months using the SDK’s forecast
method:
Display the forecast:
12-month forecast for AirPassengers data.
You may also generate forecasts for longer horizons with the timegpt-1-long-horizon
model. For example, 36 months ahead:
36-month forecast using the 'timegpt-1-long-horizon' model.
Generate a shorter-term forecast
Generate a shorter-term forecast
Forecast the next 6 months with a single command:
6-month forecast for AirPassengers data.