# OPENAI\_API\_KEY error 401

**URL:** <https://community.crewai.com/t/openai-api-key-error-401/7596>\
**Category:** CrewAI Community Support\
**Created:** [June 22, 2026, 7:27pm UTC](https://community.crewai.com/t/openai-api-key-error-401/7596 "2026-06-22T19:27:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/elan/32/5085_2.png) [@Elan](https://community.crewai.com/u/Elan)\
**Post date:** [June 22, 2026, 7:27pm UTC](https://community.crewai.com/t/openai-api-key-error-401/7596/1 "2026-06-22T19:27:13Z")

</div>

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](https://platform.openai.com/api-keys)

---

<div class="post-metadata">

**Author:** ![Michela\_Agostini](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/michela_agostini/32/4390_2.png) [@Michela\_Agostini](https://community.crewai.com/u/Michela_Agostini)\
**Post date:** [June 24, 2026, 2:41pm UTC](https://community.crewai.com/t/openai-api-key-error-401/7596/2 "2026-06-24T14:41:16Z")

</div>

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:

```auto
OPENAI_API_KEY=your_key

```

with your real OpenAI API key:

```auto
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/](https://docs.crewai.com/)
