Quickstart

TimeGPT makes forecasting straightforward with the forecast method in the Nixtla API. Pass in your DataFrame, specify the time and target columns, and call forecast. You can also visualize results with the plot method.

Important Data Requirements
Detailed guidance on data requirements is available here.



For a quick demonstration, you can launch our interactive notebook:


1

1. Install & Import Dependencies

Make sure you have the latest Nixtla Client installed, then import the required libraries:

Nixtla Client Installation
pip install nixtla
Import Libraries
import pandas as pd
from nixtla import NixtlaClient
2

2. Initialize the Nixtla Client

Provide your API key from Nixtla to authenticate:

Nixtla Client Standard Initialization
nixtla_client = NixtlaClient(
    # defaults to os.environ.get("NIXTLA_API_KEY")
    api_key='my_api_key_provided_by_nixtla'
)
3

3. Load Data & Create Forecast

Load Data and Run Forecast
# Read data
df = pd.read_csv("https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/air_passengers.csv")

# Forecast for the next 12 time steps
forecast_df = nixtla_client.forecast(
    df=df,
    h=12,
    time_col='timestamp',
    target_col="value"
)
4

4. Visualize Predictions

Plot Forecast Results
# Plot predictions
nixtla_client.plot(
    df=df,
    forecasts_df=forecast_df,
    time_col='timestamp',
    target_col='value'
)
1

Sample Logs (Optional)

Below is an example of log output when running a forecast:

TimeGPT Forecast Plot

Available models in Azure AI
To use an Azure AI endpoint for anomaly detection, set the model parameter to "azureai":

Azure AI Anomaly Detection
nixtla_client.detect_anomalies(
    ...,
    model="azureai"
)

timegpt-1

Default option for general forecasting needs.

timegpt-1-long-horizon

Optimized for extended forecast horizons. Learn more here.