Skip to content
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

OpenAI API key format validation #44

Merged
merged 2 commits into from
Sep 28, 2024
Merged

OpenAI API key format validation #44

merged 2 commits into from
Sep 28, 2024

Conversation

marklysze
Copy link
Collaborator

Why are these changes needed?

OpenAI's API key has changed in format recently and the validation function in OpenAI doesn't accurately validate the format.

OpenAI has not published the format of the key, so information gathered so far is that it can start with:
sk-
sk-proj-
sk-None-
sk-svcaat-

This is followed by segments of alphanumeric characters (including underscores) separated by dashes.

As the exact format is not defined, the regular expression in the validation function will be expanded to support keys:

  • starting with sk-
  • followed by at least 48 alphanumeric characters (including underscores and dashes)

The tests have been updated.

Related issue number

Closes #26

Checks

@marklysze marklysze added the bug Something isn't working label Sep 23, 2024
@marklysze marklysze self-assigned this Sep 23, 2024
@marklysze marklysze changed the title Updated to expand acceptable OpenAI API key format OpenAI API key format validation update Sep 23, 2024
@marklysze marklysze changed the title OpenAI API key format validation update OpenAI API key format validation Sep 23, 2024
Copy link

@0xdre 0xdre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BlocUnited
Copy link
Collaborator

I tested this PR within my use case, where I run Autogen using uvicorn. The API key validation warning issue was resolved, and everything works as expected now. Thanks for the fix!

@sonichi sonichi merged commit cd64eb3 into main Sep 28, 2024
146 of 153 checks passed
@sonichi sonichi deleted the openai_key branch September 28, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue]: is_valid_api_key needs enhancement
4 participants