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 151 forks source link

ApiError: status_code: 401 #189

Open Mzakery opened 7 months ago

Mzakery commented 7 months ago

Hello I also got the 401 error. I registered on the site and received the token, but unfortunately I still get the 401 error. please guide me

ApiError: status_code: 401, body: {'data': None, 'message': 'Invalid API key', 'details': 'Key not found', 'code': 'A12', 'requestID': 'E7F2BBTB2P', 'support': 'If you have questions or need support, please email ops@nixtla.io'}

AzulGarza commented 7 months ago

hi @Mzakery. thanks for using nixtla. could you provide an example or screenshot of how you call the sdk?

Mzakery commented 7 months ago

I registered on the website https://www.nixtla.io/ and received the token from the Get token section and defined it as a environment variable. I want to run the codes of this section

https://github.com/Nixtla/nixtla/blob/main/nbs/docs/getting-started/1_getting_started_short.ipynb

that in part timegpt.validate_token() And timegpt_fcst_df = timegpt.forecast(df=df, h=12, freq='MS', time_col='timestamp', target_col='value') timegpt_fcst_df.head()

It gives error 401

ApiError: status_code: 401, body: { 'data': None, 'message': 'Invalid API Key', 'details': 'Key not found', 'code': 'A12', 'requestID': 'E7F2BBTB2P' , 'support': 'If you have any questions or need support, please email ops@nixtla.io'}

Mzakery commented 7 months ago

Codes run in colab with version 3.10

Mzakery commented 6 months ago

load_dotenv('c.env') True TIMEGPT_TOKEN=os.environ.get("TIMEGPT_TOKEN") TIMEGPT_TOKEN '... token...' timegpt = TimeGPT(

defaults to os.environ.get("TIMEGPT_TOKEN")

token = 'TIMEGPT_TOKEN')

timegpt.validate_token()

ApiError Traceback (most recent call last) in <cell line: 1>() ----> 1 timegpt.validate_token()

1 frames /usr/local/lib/python3.10/dist-packages/nixtlats/timegpt.py in validate_token(self, log) 725 def validate_token(self, log: bool = True) -> bool: 726 """Returns True if your token is valid.""" --> 727 validation = self.client.validate_token() 728 valid = False 729 if "message" in validation:

/usr/local/lib/python3.10/dist-packages/nixtlats/client.py in validate_token(self) 419 except JSONDecodeError: 420 raise ApiError(status_code=_response.status_code, body=_response.text) --> 421 raise ApiError(status_code=_response.status_code, body=_response_json) 422 423 def validate_token_front(self) -> typing.Any:

ApiError: status_code: 401, body: {'data': None, 'message': 'Invalid API key', 'details': 'Key not found', 'code': 'A12', 'requestID': 'RQVKJPWP2N', 'support': 'If you have questions or need support, please email ops@nixtla.io'}

AzulGarza commented 6 months ago

hey @Mzakery!

Thanks for using TimeGPT.

I think the problem is related to this line:

timegpt = TimeGPT(
# defaults to os.environ.get("TIMEGPT_TOKEN")
token = 'TIMEGPT_TOKEN')

There, you're passing the string 'TIMEGPT_TOKEN' as a token. Instead, since you're loading your env variables, just timegpt = TimeGPT() should work. Alternatively, simply removing the quotes to access the TIMEGPT_TOKEN object should work as well,

timegpt = TimeGPT(token=TIMEGPT_TOKEN)
Mzakery commented 6 months ago

Thanks But it gives error 429 in this part.

timegpt.validate_token()

ApiError Traceback (most recent call last) in <cell line: 1>() ----> 1 timegpt.validate_token()

1 frames /usr/local/lib/python3.10/dist-packages/nixtlats/client.py in validate_token(self) 419 except JSONDecodeError: 420 raise ApiError(status_code=_response.status_code, body=_response.text) --> 421 raise ApiError(status_code=_response.status_code, body=_response_json) 422 423 def validate_token_front(self) -> typing.Any:

ApiError: status_code: 429, body: {'data': None, 'message': 'Too many requests', 'details': 'You have reached your request limit, email ops@nixtla.io to continue using the API', 'code': 'A20', 'requestID': '868HB5JZ5T', 'support': 'If you have questions or need support, please email ops@nixtla.io'}