-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(api): implement get_api_key utility for API key validation #2114
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think raising an error needs to be in verify_api_key or change the function's name to get_api_key.
Hey @MisileLab, thanks for the feedback. I've updated the code as suggested—I've renamed the function to get_api_key and incorporated the error-raising logic directly within it. Let me know if you need any further adjustments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just don't forget to change pr's description.
(verify_api_key to get_api_key)
Hey @MisileLab, I updated the PR description to replace all instances of |
This PR introduces a new utility function,
get_api_key
, to validate API key environment variables more effectively. Previously, if an API key ENV var was empty, the error raised during API calls was ambiguous. With this update, we now check for empty API keys upfront and return a clearer, descriptive error message.Changes include:
get_api_key
function insrc/openai/_utils/_utils.py
.src/openai/_client.py
andsrc/openai/lib/azure.py
to leverage the new utility.This change addresses issue #2092 by ensuring that an exception is thrown when API key ENV vars are empty, thus improving error reporting clarity. I'm grateful for the feedback, and I'll continue to monitor any responses from the OpenAI team.
Thank you for your time and consideration!