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

1

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.

2

Install Nixtla

Install the Nixtla library in your preferred Python environment:

Install Nixtla
pip install nixtla
3

Import the Nixtla TimeGPT client

Import the Nixtla client and instantiate it with your API key:

Nixtla Client Setup
from nixtla import NixtlaClient

nixtla_client = NixtlaClient(
    api_key='my_api_key_provided_by_nixtla'
)

Verify the status and validity of your API key:

Validate API Key
nixtla_client.validate_api_key()

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.

Load AirPassengers Data
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/air_passengers.csv')
df.head()
timestampvalue
01949-01-01112
11949-02-01118
21949-03-01132
31949-04-01129
41949-05-01121

Plot the dataset:

Plot AirPassengers Data
nixtla_client.plot(df, time_col='timestamp', target_col='value')

Historical AirPassengers data from 1949 to 1960.

Short and Long-Term Forecasting Examples