crewAI: Unauthorized Error (403) when Using SERPER_API_KEY for Google Search

Description:

Whenever the software attempts to search in Google using the SERPER_API_KEY, I encounter an unauthorized error despite the API key being set correctly.

Steps to Reproduce:

  1. Run the software with the correctly set SERPER_API_KEY.
  2. Trigger a Google search action, such as
Action: Search the internet
Action Input: {"search_query": "Predictions for used car market in 2024"}

Expected Result:

The software should perform the Google search and return the relevant results.

Actual Result:

The following error message is returned:

{'message': 'Unauthorized.', 'statusCode': 403}

Additional Context:

Log Output:

> Entering new CrewAgentExecutor chain...
To accomplish this task, the first thing I need to do is to gather data about the current trends in the used car market, factors that influence the prices, and any predictions available for 2024. This will allow me to make an educated guess about whether the prices of used cars will go up or down in 2024.

Action: Search the internet
Action Input: {"search_query": "Predictions for used car market in 2024"} 

{'message': 'Unauthorized.', 'statusCode': 403}

Environment:

Software Version:

  • crewai 0.28.8
  • crewai-tools 0.1.6
  • Python 3.12.3
  • pip 24.0

Operating System: Windows Additional Details: Jupyter

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Newbie here, but I had a similar issue. It was very, very frustrating… I had gotten an API key from scaleserp.com, but I finally figured out what was actually required was an API key from serper.dev. Now all of those SerperDevTool searches are working for me.

I got the exact same issue with the latest versions.

pip install crewai==0.30.11 crewai_tools==0.2.6 langchain_community