nixtla icon indicating copy to clipboard operation
nixtla copied to clipboard

KeyError: 'TIMEGPT_TOKEN'

Open xiaolongluo1979 opened this issue 2 years ago • 2 comments

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' ?

xiaolongluo1979 avatar Oct 15 '23 21:10 xiaolongluo1979

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

talrejanikhil avatar Oct 17 '23 15:10 talrejanikhil

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()

MateKristof avatar Oct 28 '23 16:10 MateKristof

@xiaolongluo1979 You can get an API key here

elephaint avatar Jul 30 '24 20:07 elephaint