is_valid_api_key

is_valid_api_key(api_key: str) -> bool

Determine if input is valid OpenAI API key. As of 2024-09-24 there’s no official definition of the key structure so we will allow anything starting with “sk-” and having at least 48 alphanumeric (plus underscore and dash) characters. Keys are known to start with “sk-”, “sk-proj”, “sk-None”, and “sk-svcaat”

Parameters:
NameDescription
api_keyAn input string to be validated.

Type: str
Returns:
TypeDescription
boolbool: A boolean that indicates if input is valid OpenAI API key.