# Creating Agents
embedder_config = {
"provider": "google",
"config": {
"api_key": os.environ.get("GOOG2_API_KEY"),
"model": "models/text-embedding-004"
}
}
market_news_monitor_agent = Agent(
config=agents_config['market_news_monitor_agent'],
tools=[SerperDevTool(), ScrapeWebsiteTool()],
llm=groq_llm,
embedder=embedder_config
)
data_analyst_agent = Agent(
config=agents_config['data_analyst_agent'],
tools=[SerperDevTool(), WebsiteSearchTool()],
llm=groq_llm,
embedder=embedder_config
)
content_creator_agent = Agent(
config=agents_config['content_creator_agent'],
tools=[SerperDevTool(), WebsiteSearchTool()],
embedder=embedder_config
)
quality_assurance_agent = Agent(
config=agents_config['quality_assurance_agent'],
embedder=embedder_config
)
# Creating Tasks
monitor_financial_news_task = Task(
config=tasks_config['monitor_financial_news'],
agent=market_news_monitor_agent
)
analyze_market_data_task = Task(
config=tasks_config['analyze_market_data'],
agent=data_analyst_agent
)
create_content_task = Task(
config=tasks_config['create_content'],
agent=content_creator_agent,
context=[monitor_financial_news_task, analyze_market_data_task]
)
quality_assurance_task = Task(
config=tasks_config['quality_assurance'],
agent=quality_assurance_agent,
output_pydantic=ContentOutput
)
# Creating Crew
content_creation_crew = Crew(
agents=[
market_news_monitor_agent,
data_analyst_agent,
content_creator_agent,
quality_assurance_agent
],
tasks=[
monitor_financial_news_task,
analyze_market_data_task,
create_content_task,
quality_assurance_task
],
verbose=True,
embedder=embedder_config
)
Error:
KeyError Traceback (most recent call last) Cell In[8], [line 19](vscode-notebook-cell:?execution_count=8&line=19) [2](vscode-notebook-cell:?execution_count=8&line=2) embedder_config = { [3](vscode-notebook-cell:?execution_count=8&line=3) "provider": "google", [4](vscode-notebook-cell:?execution_count=8&line=4) "config": { (...) [7](vscode-notebook-cell:?execution_count=8&line=7) } [8](vscode-notebook-cell:?execution_count=8&line=8) } [10](vscode-notebook-cell:?execution_count=8&line=10) market_news_monitor_agent = Agent( [11](vscode-notebook-cell:?execution_count=8&line=11) config=agents_config['market_news_monitor_agent'], [12](vscode-notebook-cell:?execution_count=8&line=12) tools=[SerperDevTool(), ScrapeWebsiteTool()], [13](vscode-notebook-cell:?execution_count=8&line=13) llm=groq_llm, [14](vscode-notebook-cell:?execution_count=8&line=14) embedder=embedder_config [15](vscode-notebook-cell:?execution_count=8&line=15) ) [17](vscode-notebook-cell:?execution_count=8&line=17) data_analyst_agent = Agent( [18](vscode-notebook-cell:?execution_count=8&line=18) config=agents_config['data_analyst_agent'], ---> [19](vscode-notebook-cell:?execution_count=8&line=19) tools=[SerperDevTool(), WebsiteSearchTool()], [20](vscode-notebook-cell:?execution_count=8&line=20) llm=groq_llm, [21](vscode-notebook-cell:?execution_count=8&line=21) embedder=embedder_config [22](vscode-notebook-cell:?execution_count=8&line=22) ) [24](vscode-notebook-cell:?execution_count=8&line=24) content_creator_agent = Agent( [25](vscode-notebook-cell:?execution_count=8&line=25) config=agents_config['content_creator_agent'], [26](vscode-notebook-cell:?execution_count=8&line=26) tools=[SerperDevTool(), WebsiteSearchTool()], [27](vscode-notebook-cell:?execution_count=8&line=27) embedder=embedder_config
...
[21](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/username/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/embedchain/embedder/openai.py:21) if api_key is None and os.getenv("OPENAI_ORGANIZATION") is None: File <frozen os>:714, in __getitem__(self, key) KeyError: 'OPENAI_API_KEY'
-
Try removing every
embedder=embedder_config
line from your code (both from theAgent
s and theCrew
). From the code you provided, it looks like that parameter isn’t actually being used anywhere, since you’re just working with basic tools. -
Show how you’re defining
groq_llm
.
I am using your tutorial Max, the one that you used in deeplearning - l_5.ipynb. where you have used groq_llm = “groq/llama-3.3-70b-versatile”. But you have not set any embedder as you use openAI by default for everything. I do NOTT have openAI subscription. I need to use google embedder. I tried the following provided by your crewAI portal’s search field tool that I guess used your docs to advise me with a code snippet:
embedder_config = {
“provider”: “google”,
“config”: {
“api_key”: os.environ.get(“GOOG2_API_KEY”),
“model”: “models/text-embedding-004”
}
}
I used embedder=embedder_config for all the agents.
I kept getting the same openAI key error, hence tried adding it to crew instantiation as well as suggested by your crewAI search field.
I have already shared my code that defines the embedder, agents, tasks and the crew, and the error message as well.
I am surprised you dont get what is causing the error.
its clear - your crewAI uses OPENAI every where, all through out the framework, though you and your team claim that default behavior can be overridden with a parameter. it is not working consistently.
hope you get my point.
@mayon, hey buddy, I think I need to clear a few things up.
First off, there’s no such thing as “my tutorial.” I’m not on the CrewAI team; I’m just a regular user like you, trying to help make this forum a productive place to learn, where I actually use other folks’ questions to drive my own studies. Honestly, I have absolutely no idea which tutorial or course you’re referring to. The only “course” I’ve taken myself since I decided to jump into CrewAI less than three months ago was pretty much just digging through a good chunk of its source code. So, yeah, I’m really not sure which tutorial you mean.
Here are a few resources that will definitely help you get a solid grasp of things:
- The documentation on LLMs – you’ll find a section there on “Provider Configuration Examples” that breaks down how to set up LLMs from all sorts of providers, no OpenAI needed.
- The documentation on Knowledge Sources, which has a dedicated section on “Embeddings Configuration.” That’s where you’ll learn how to set up different embedding models and get the hang of them.
- RAG tools also use embeddings. So, I picked the documentation for the
PDFSearchTool
as an example. You’ll see an example there too of using a custom model and embeddings. - @tonykipkemboi’s YouTube channel – he actually is part of the CrewAI team, and on his channel, you’ll find a wealth of tutorials covering different levels of complexity.
- And, of course, the official CrewAI YouTube channel.
Go at your own pace, understand things bit by bit, run the simpler examples first, and only then gradually ramp up the complexity. And when you do hit a snag or have a question, make sure to provide a complete example that lets others reproduce your error or understand your doubt – always a simple, to-the-point version that clearly lays out your question. Doing that will seriously boost your chances of getting help.
Best of luck on your journey!
I am passing gemini model to all the agents, gemini embedder to the tools where it would be needed. but I still get the following error. I even tried with dummy key for OpenAI, but nothing works:
│ │ ❌ LLM Call Failed │ │ Error: litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key provided: │ │ dummy-ke************************ency. You can find your API key at │ │ https://platform.openai.com/account/api-keys. │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
2025-05-23 18:45:46,265 - 22552 - llm.py-llm:905 - ERROR: LiteLLM call failed: litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key provided: dummy-ke************************ency. You can find your API key at https://platform.openai.com/account/api-keys.
Error during LLM call: litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key provided: dummy-ke************************ency. You can find your API key at https://platform.openai.com/account/api-keys. An unknown error occurred. Please check the details below. Error details: litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key provided: dummy-ke************************ency. You can find your API key at https://platform.openai.com/account/api-keys.
🚀 Crew: crew ├── 📋 Task: bb465690-a8ff-42be-baf9-21891549e1a4 │ Assigned to: Lead Market Analyst │ │ Status: ✅ Completed │ └── 🤖 Agent: Lead Market Analyst │ │ Status: ✅ Completed ├── 📋 Task: 48338eb3-31c6-441e-bae4-e7f859e61f5b │ Assigned to: Chief Data Strategist │ │ Status: ✅ Completed │ └── 🤖 Agent: Chief Data Strategist │ │ Status: ✅ Completed └── 📋 Task: 6d18b28f-d2cb-47c6-8c68-41827357badf Assigned to: Creative Content Director Status: ❌ Failed └── 🤖 Agent: Creative Content Director Status: In Progress
╭───────────────────────────────────────────────── Task Failure ──────────────────────────────────────────────────╮ │ │ │ Task Failed │ │ Name: 6d18b28f-d2cb-47c6-8c68-41827357badf │ │ Agent: Creative Content Director │ │ │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────── Crew Failure ──────────────────────────────────────────────────╮ │ │ │ Crew Execution Failed │ │ Name: crew │ │ ID: 752b7aad-55b2-4a4a-8a30-46276398c67a │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
--------------------------------------------------------------------------- AuthenticationError Traceback (most recent call last) File ~\AppData\Roaming\Python\Python312\site-packages\litellm\llms\openai\openai.py:725, in OpenAIChatCompletion.completion(self, model_response, timeout, optional_params, litellm_params, logging_obj, model, messages, print_verbose, api_key, api_base, api_version, dynamic_params, azure_ad_token, acompletion, logger_fn, headers, custom_prompt_dict, client, organization, custom_llm_provider, drop_params) [724](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:724) else: --> [725](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:725) raise e [726](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:726) except OpenAIError as e: File ~\AppData\Roaming\Python\Python312\site-packages\litellm\llms\openai\openai.py:653, in OpenAIChatCompletion.completion(self, model_response, timeout, optional_params, litellm_params, logging_obj, model, messages, print_verbose, api_key, api_base, api_version, dynamic_params, azure_ad_token, acompletion, logger_fn, headers, custom_prompt_dict, client, organization, custom_llm_provider, drop_params) [639](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:639) logging_obj.pre_call( [640](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:640) input=messages, [641](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:641) api_key=openai_client.api_key, (...) [647](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:647) }, [648](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:648) ) [650](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:650) ( [651](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:651) headers, [652](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:652) response, --> [653](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:653) ) = self.make_sync_openai_chat_completion_request( [654](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:654) openai_client=openai_client, [655](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:655) data=data, [656](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:656) timeout=timeout, [657](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:657) logging_obj=logging_obj, [658](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:658) ) [660](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/llms/openai/openai.py:660) logging_obj.model_call_details["response_headers"] = headers
...
[410](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:410) ) [411](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:411) elif original_exception.status_code == 404: [412](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/AnnamalaiArunachalam/PythonProjects/crewai_project_planning/~/AppData/Roaming/Python/Python312/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:412) exception_mapping_worked = True AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key provided: dummy-ke************************ency. You can find your API key at https://platform.openai.com/account/api-keys.
Sorry, I thought you are part of crew AI. Thanks for letting me know, you are an user like me. I know about using other LLMs and embedding models - that crewAI claims to support. I have used them with agents and it has worked in other examples. But in this case, the code that I shared earlier where the tools require embedder and the agents with LLM, when I passed Gemini models, the error message still looks for OpenAI API key. I have passed the custom LLM to all the agents and the embedder to all the tools. if the code still throws error, its crewAIs package which has hardcoded model where it doesn’t take the custom LLM. I quoted tutorial becos, i took the entire code from an example provided by crewAI’s CEO which discusses this example as L-5.ipynb. I assumed you are part of crewAI and hence referred to the code from the site. thanks for responding to all my queries. appreciate that.