Skip to main content

TimeGPT-2 Family of Foundation Models

TimeGPT-2 and TimeGPT-2.1 are the latest versions of our enterprise-grade models, built to reliably solve mission-critical time-series problems. The TimeGPT-2 family of models is optimized for enterprise needs, prioritizing accuracy and stability with a privacy-first approach and full support for self-hosted and on-premises deployments.

Set Up TimeGPT-2 family of models for Python Time Series Forecasting

Step 1: Confirm Access and get an API Key

  • Confirm with [email protected] that your account has access to these latest models.
  • Get your API key from dashboard.nixtla.io. Note that you can also use your existing keys as long as your account has access to these latest models (Step 1 above).
    • 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 and save it in a safe place for use later.
Dashboard for TimeGPT API keys

TimeGPT dashboard showing API key management interface for Python forecasting

Step 2: Install Nixtla

Install the Nixtla library in your preferred Python environment. In order to use the TimeGPT-2 family of models, the client version must be >= 0.7.0.
pip install nixtla>=0.7.0
You can verify the client version installed using the following code. It should return a version >= 0.7.0
from nixtla import __version__
print(__version__)
0.7.2

Step 3: Import the Nixtla TimeGPT client

Import the Nixtla client and instantiate it with your API key and base URL for TimeGPT-2 family:
from nixtla import NixtlaClient

nixtla_client = NixtlaClient(
    base_url = 'https://api-preview.nixtla.io',  # Needed for TimeGPT-2 family
    api_key='my_api_key_provided_by_nixtla'
)
Verify the status and validity of your API key:
nixtla_client.validate_api_key()
True

Forecasting with TimeGPT-2 family

Load your time series 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

Generate the forecast

Forecast the next 12 months using the SDK’s forecast method. You can switch the model to any of the TimeGPT-2 family of models - timegpt-2-pro, timegpt-2-lab, timegpt-2-mini, timegpt-2.1
timegpt_fcst_df = nixtla_client.forecast(
    df,
    h=12,
    time_col="timestamp",
    target_col="value",
    model="timegpt-2.1",
)

Plot the forecast

nixtla_client.plot(df, timegpt_fcst_df, time_col='timestamp', target_col='value')
Forecasted Plot

TimeGPT 12-month forecast visualization with confidence intervals for AirPassengers dataset

Summary

Using the TimeGPT-2 family of models is similar to using the TimeGPT-1 family with the following changes. In order to use TimeGPT-2 family of models
  • Make sure that your account has access to these models
  • Install the latest Nixtla client (>= 0.7.0)
  • Make sure you use the right base_url while instantiating the client along with your API key.
Happy forecasting!