So I just updated my crewai to 0.76.9.
I setup my first model, and chose “groq” to be my main llm.
Gave my API key and the project was ready to run.
When i ran “crewai run”, it gave me following error saying OPENAI_API_KEY couldn’t be found. The detailed error is below.
PS E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai> crewai run
Running the Crew
Using CPython 3.12.0 interpreter at: D:\Programs\Python\Python312\python.exe
Creating virtual environment at: .venv
Built test-non-openai @ file:///E:/Work/Practice/7.%20GenAI%20Practice/00.PRACTICE/Learn/test_non_openai
░░░░░░░░░░░░░░░░░░░░ [0/217] Installing wheels... warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
If the cache and target directories are on different filesystems, hardlinking may not be supported.
If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 217 packages in 17.98s
E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\pysbd\segmenter.py:66: SyntaxWarning: invalid escape sequence '\s'
for match in re.finditer('{0}\s*'.format(re.escape(sent)), self.original_text):
E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\pysbd\lang\arabic.py:29: SyntaxWarning: invalid escape sequence '\.'
txt = re.sub('(?<={0})\.'.format(am), '∯', txt)
E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\pysbd\lang\persian.py:29: SyntaxWarning: invalid escape sequence '\.'
txt = re.sub('(?<={0})\.'.format(am), '∯', txt)
# Agent: AI LLMs Senior Data Researcher
## Task: Conduct a thorough research about AI LLMs Make sure you find any interesting and relevant information given the current year is 2024.
2024-10-31 02:29:57,752 - 21892 - llm.py-llm:161 - ERROR: LiteLLM call failed: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
# Agent: AI LLMs Senior Data Researcher
## Task: Conduct a thorough research about AI LLMs Make sure you find any interesting and relevant information given the current year is 2024.
2024-10-31 02:29:57,770 - 21892 - llm.py-llm:161 - ERROR: LiteLLM call failed: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
# Agent: AI LLMs Senior Data Researcher
## Task: Conduct a thorough research about AI LLMs Make sure you find any interesting and relevant information given the current year is 2024.
2024-10-31 02:29:57,793 - 21892 - llm.py-llm:161 - ERROR: LiteLLM call failed: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 854, in completion
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 767, in completion
openai_client: OpenAI = self._get_openai_client( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 575, in _get_openai_client
_new_client = OpenAI(
^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\openai\_client.py", line 105, in __init__
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 1587, in completion
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 1560, in completion
response = openai_chat_completions.completion(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 864, in completion
raise OpenAIError(
litellm.llms.OpenAI.openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agent.py", line 236, in execute_task
result = self.agent_executor.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 93, in invoke
formatted_answer = self._invoke_loop()
^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 175, in _invoke_loop
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 115, in _invoke_loop
answer = self.llm.call(
^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\llm.py", line 155, in call
response = litellm.completion(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\utils.py", line 1013, in wrapper
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\utils.py", line 903, in wrapper
result = original_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 2999, in completion
raise exception_type(
^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 2116, in exception_type
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 310, in exception_type
raise AuthenticationError(
litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 854, in completion
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 767, in completion
openai_client: OpenAI = self._get_openai_client( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 575, in _get_openai_client
_new_client = OpenAI(
^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\openai\_client.py", line 105, in __init__
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 1587, in completion
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 1560, in completion
response = openai_chat_completions.completion(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 864, in completion
raise OpenAIError(
litellm.llms.OpenAI.openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agent.py", line 236, in execute_task
result = self.agent_executor.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 93, in invoke
formatted_answer = self._invoke_loop()
^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 175, in _invoke_loop
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 115, in _invoke_loop
answer = self.llm.call(
^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\llm.py", line 155, in call
response = litellm.completion(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\utils.py", line 1013, in wrapper
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\utils.py", line 903, in wrapper
result = original_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 2999, in completion
raise exception_type(
^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 2116, in exception_type
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 310, in exception_type
raise AuthenticationError(
litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 854, in completion
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 767, in completion
openai_client: OpenAI = self._get_openai_client( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 575, in _get_openai_client
_new_client = OpenAI(
^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\openai\_client.py", line 105, in __init__
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 1587, in completion
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 1560, in completion
response = openai_chat_completions.completion(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\llms\OpenAI\openai.py", line 864, in completion
raise OpenAIError(
litellm.llms.OpenAI.openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Scripts\run_crew.exe\__main__.py", line 8, in <module>
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\src\test_non_openai\main.py", line 17, in run
TestNonOpenaiCrew().crew().kickoff(inputs=inputs)
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\crew.py", line 494, in kickoff
result = self._run_sequential_process()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\crew.py", line 598, in _run_sequential_process
return self._execute_tasks(self.tasks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\crew.py", line 696, in _execute_tasks
task_output = task.execute_sync(
^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\task.py", line 191, in execute_sync
return self._execute_core(agent, context, tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\task.py", line 247, in _execute_core
result = agent.execute_task(
^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agent.py", line 248, in execute_task
result = self.execute_task(task, context, tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agent.py", line 248, in execute_task
result = self.execute_task(task, context, tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agent.py", line 247, in execute_task
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agent.py", line 236, in execute_task
result = self.agent_executor.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 93, in invoke
formatted_answer = self._invoke_loop()
^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 175, in _invoke_loop
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\agents\crew_agent_executor.py", line 115, in _invoke_loop
answer = self.llm.call(
^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\crewai\llm.py", line 155, in call
response = litellm.completion(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\utils.py", line 1013, in wrapper
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\utils.py", line 903, in wrapper
result = original_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\main.py", line 2999, in completion
raise exception_type(
^^^^^^^^^^^^^^^
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 2116, in exception_type
raise e
File "E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai\.venv\Lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 310, in exception_type
raise AuthenticationError(
litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.
PS E:\Work\Practice\7. GenAI Practice\00.PRACTICE\Learn\test_non_openai>
I tried again, made sure that all steps are clear. But same result.
I have spent hours working around this problem. immersed myself in crewai docs and groq docs but couldn’t find anything besides the repeated things I have already tried several times.
Then I tried the same with gemini
. Exact same issue. Can someone please help?