From b99eb743f915a9497fc7b56d5e34a6a87e3fec28 Mon Sep 17 00:00:00 2001 From: Ashish Gapat Date: Mon, 13 May 2024 03:35:58 +0530 Subject: [PATCH] fix: update key validation to work with OpenAI's new project keys (#98) 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-")); }