togethercomputer / together-python

The Official Python Client for Together's API
https://pypi.org/project/together/
Apache License 2.0
31 stars 7 forks source link

Handle errors gracefully #53

Closed orangetin closed 11 months ago

orangetin commented 11 months ago

Output from CLI:

10-26-2023 14:09:17 - together.commands.complete - CRITICAL - TOGETHER_API_KEY not found.
Please set it as an environment variable or set it as together.api_key
Find your TOGETHER_API_KEY at https://api.together.xyz/settings/api-keys (complete.py:147)

Output from library:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/abhy/coding/github.com/together/src/together/complete.py", line 41, in create
    response = create_post_request(
  File "/Users/abhy/coding/github.com/together/src/together/utils.py", line 86, in create_post_request
    verify_api_key()
  File "/Users/abhy/coding/github.com/together/src/together/utils.py", line 58, in verify_api_key
    raise together.AuthenticationError(together.MISSING_API_KEY_MESSAGE)
together.error.AuthenticationError: TOGETHER_API_KEY not found.
Please set it as an environment variable or set it as together.api_key
Find your TOGETHER_API_KEY at https://api.together.xyz/settings/api-keys