From ff22e009de647d5246f550e2a76e32f7fc31e32e Mon Sep 17 00:00:00 2001 From: Ashish Gapat Date: Fri, 10 May 2024 18:39:21 +0530 Subject: [PATCH] Update key validation to work with OpenAI's new project keys fixes #97 OpenAI has introduced project keys as the new default over user keys (See: https://help.openai.com/en/articles/9186755-managing-your-work-in-the-api-platform-with-projects). This was a breaking change for those with old 'user keys', causing the validation to fail. Change itself was simple, consisting of 1 line at /src/utils/apikey.ts --- src/utils/apikey.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/apikey.ts b/src/utils/apikey.ts index addf041..8f65d43 100644 --- a/src/utils/apikey.ts +++ b/src/utils/apikey.ts @@ -1,3 +1,3 @@ export function isValidAPIKey(apiKey: string | null) { - return apiKey?.length == 51 && apiKey?.startsWith("sk-"); + return (apiKey?.length === 51 && apiKey.startsWith("sk-")) || (apiKey?.length === 56 && apiKey.startsWith("sk-proj-")); }