Failed to init knowledge: Please provide an OpenAI API key

I am trying to get the resume-optimization-crew to work. I followed all the instructions and am getting this error:

Traceback (most recent call last):
File “D:\ProgramData\Python\Python312\Lib\site-packages\crewai\agent.py”, line 150, in set_knowledge
self.knowledge = Knowledge(
^^^^^^^^^^
File “D:\ProgramData\Python\Python312\Lib\site-packages\crewai\knowledge\knowledge.py”, line 39, in init
self.storage = KnowledgeStorage(
^^^^^^^^^^^^^^^^^
File “D:\ProgramData\Python\Python312\Lib\site-packages\crewai\knowledge\storage\knowledge_storage.py”, line 56, in init
self._set_embedder_config(embedder)
File “D:\ProgramData\Python\Python312\Lib\site-packages\crewai\knowledge\storage\knowledge_storage.py”, line 202, in _set_embedder_config
else self._create_default_embedding_function()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\ProgramData\Python\Python312\Lib\site-packages\crewai\knowledge\storage\knowledge_storage.py”, line 188, in _create_default_embedding_function
return OpenAIEmbeddingFunction(
^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\ProgramData\Python\Python312\Lib\site-packages\chromadb\utils\embedding_functions\openai_embedding_function.py”, line 56, in init
raise ValueError(
ValueError: Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keys

I definitely have OPENAI_AP_KEY set in the .env file.
I’ve tried several things including recreating the .env file and I continue to get this.

I’ve worked with stock_analyst project before and did not have this problem. I am using the same API key which I know works.

python --version
Python 3.12.8

It looks like you need to set the embedder model. As a starting point, I’d suggest following the code found in this other thread about it. Specifically, check the embedder_config setup.

If the problem still persists after you adapt the example to your use case, feel free to come back here and provide more details – preferably with some code.

Not sure I’m following your answer. I downloaded the source from GitHub - tonykipkemboi/resume-optimization-crew: AI-powered resume optimization using CrewAI. Analyzes job postings, scores resume matches, and provides tailored improvements with multiple AI agents. Built for job seekers to maximize their application success. and did not make any modifications. But I did create the .env file and did add my OPENAI_API_KEY and SERPER_API_KEY. Based on project instructions, it does not look like it is asking me to change any of the source code to make it work.

I took a look at the project you mentioned. It seems like a pretty standard CrewAI setup, so could you just double-check that you created your .env file in the same folder as the .env.example file from the repository?

Ideally, you can just rename .env.example to .env and then make sure your API keys are correct in there:

MODEL=o1
OPENAI_API_KEY=your_openai_api_key
SERPER_API_KEY=your_serper_api_key