Skip to content

Commit

Permalink
fix: update key validation to work with OpenAI's new project keys (#98)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AshishGapat authored May 12, 2024
1 parent 193b862 commit b99eb74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/apikey.ts
Original file line number Diff line number Diff line change
@@ -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-"));
}

0 comments on commit b99eb74

Please sign in to comment.