Nixtla / nixtla

TimeGPT-1: production ready pre-trained Time Series Foundation Model for forecasting and anomaly detection. Generative pretrained transformer for time series trained on over 100B data points. It's capable of accurately predicting various domains such as retail, electricity, finance, and IoT with just a few lines of code 🚀.
https://docs.nixtla.io
Other
1.91k stars 153 forks source link

KeyError: 'TIMEGPT_TOKEN' #128

Open xiaolongluo1979 opened 8 months ago

xiaolongluo1979 commented 8 months ago

This may be a naive question as I am not a developer ...

After installing nixtlats (via !pip install nixtlats on jupyter notebook), I was trying the simple codes provided but got the following error:

KeyError Traceback (most recent call last) /tmp/ipykernel_6602/2071313601.py in 2 3 from nixtlats import TimeGPT ----> 4 timegpt = TimeGPT(token=os.environ['TIMEGPT_TOKEN']) 5 fcst_df = timegpt.forecast(df, h=24, level=[80, 90])

~/anaconda3/lib/python3.9/os.py in getitem(self, key) 677 except KeyError: 678 # raise KeyError with the original key value --> 679 raise KeyError(key) from None 680 return self.decodevalue(value) 681

KeyError: 'TIMEGPT_TOKEN'

How do I get the 'TIMEGPT_TOKEN' ?

talrejanikhil commented 8 months ago

Have you obtained a Time GPT token and set it as a environment variable? You can get a token here - https://dashboard.nixtla.io/

MateKristof commented 8 months ago

You should create an .env file in the project directory and paste the API key into it. As seen here: image Then install python dotenv.

pip install python-dotenv

And use this lines in your example file to load environment:

from dotenv import load_dotenv
load_dotenv()