Add a better API KEY validation in the client

This commit is contained in:
Saurabh Misra 2024-01-22 16:23:08 -08:00
parent 9ea6de6e1a
commit 5d94c59d3b

View file

@ -11,6 +11,12 @@ def get_codeflash_api_key() -> Optional[str]:
+ "You can generate one at https://app.codeflash.ai/app/apikeys,\n"
+ "then set it as a CODEFLASH_API_KEY environment variable."
)
if not api_key.startswith("cf-"):
raise EnvironmentError(
f"CodeFlash API key is invalid. It should start with a 'cf-' prefix, we found '{api_key}' instead.\n"
+ "You can generate one at https://app.codeflash.ai/app/apikeys,\n"
+ "then set it as a CODEFLASH_API_KEY environment variable."
)
return api_key