File tree 2 files changed +2
-1
lines changed
2 files changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ def is_valid_api_key(api_key: str) -> bool:
90
90
Returns:
91
91
bool: A boolean that indicates if input is valid OpenAI API key.
92
92
"""
93
- api_key_re = re .compile (r"^sk-[A-Za-z0-9]{32,}$" )
93
+ api_key_re = re .compile (r"^sk-(proj-)? [A-Za-z0-9]{32,}$" )
94
94
return bool (re .fullmatch (api_key_re , api_key ))
95
95
96
96
Original file line number Diff line number Diff line change @@ -382,6 +382,7 @@ def test_is_valid_api_key():
382
382
assert not is_valid_api_key ("sk-asajsdjsd22372%23kjdfdfdf2329ffUUDSDS" )
383
383
assert is_valid_api_key ("sk-asajsdjsd22372X23kjdfdfdf2329ffUUDSDS" )
384
384
assert is_valid_api_key ("sk-asajsdjsd22372X23kjdfdfdf2329ffUUDSDS1212121221212sssXX" )
385
+ assert is_valid_api_key ("sk-proj-asajsdjsd22372X23kjdfdfdf2329ffUUDSDS12121212212" )
385
386
assert is_valid_api_key (MOCK_OPEN_AI_API_KEY )
386
387
387
388
You can’t perform that action at this time.
0 commit comments