Open AI API Key missing

67 views Asked by At

I have been using open ai for a while in many projects, today i created a new apiKey for my new project, whene i initialize open ai i get this error:

Unhandled Runtime Error Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).

code:

import OpenAI from 'openai';

export const openai = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

The apiKey is in my .env and also in my openAi portal

Whats happening??

Thanks!!

0

There are 0 answers