add openai validation
This commit is contained in:
13
app/home/(user)/_lib/server/is-valid-open-ai-env.ts
Normal file
13
app/home/(user)/_lib/server/is-valid-open-ai-env.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import OpenAI from 'openai';
|
||||
|
||||
export const isValidOpenAiEnv = async () => {
|
||||
const client = new OpenAI();
|
||||
|
||||
try {
|
||||
await client.models.list();
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.log('No openAI env');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user