OPENAI_API_KEY error 401

I have placed the API key in the .env file. But acter running crewai run I get the following error:

openai.AuthenticationError: Error code: 401 - {‘error’: {‘message’: 'Incorrect API key provided: your_key.

I can see my KEY on the openAI web site at https://platform.openai.com/api-keys

Taking into consideration the kind of error message you have, in my view your .env file contains the placeholder value your_key instead of your actual API key.

To solve the issue my suggestion is the following:

Open your .env file and replace:

OPENAI_API_KEY=your_key

with your real OpenAI API key:

OPENAI_API_KEY=sk-...

Make sure the key starts with sk- and is copied correctly from your OpenAI account!

Happy coding!

Michela

PS 1 : Sharing your OpenAI API key is risky!! Next time do not share the link as you did.
PS 2 : More info could be found in https://docs.crewai.com/