# Gemini API 404 error

**URL:** <https://community.crewai.com/t/gemini-api-404-error/3909>\
**Category:** CrewAI Community Support\
**Created:** [February 17, 2025, 10:42am UTC](https://community.crewai.com/t/gemini-api-404-error/3909 "2025-02-17T10:42:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Debashis\_Bora](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/debashis_bora/32/1878_2.png) [@Debashis\_Bora](https://community.crewai.com/u/Debashis_Bora)\
**Post date:** [February 17, 2025, 10:42am UTC](https://community.crewai.com/t/gemini-api-404-error/3909/1 "2025-02-17T10:42:07Z")

</div>

I am getting this error while running this, please help

!pip install crewai==0.74.2 crewai\_tools langchain\_community

import warnings  
warnings.filterwarnings(‘ignore’)

from crewai import Agent, Task, Crew, LLM  
import os

GEMINI\_API\_KEY = " "

# Optionally, set the API key as an environment variable.

os.environ[“GEMINI\_API\_KEY”] = GEMINI\_API\_KEY

llm = LLM(  
model=“gemini-1.5-flash”,  
temperature=0.7,  
gemini\_api\_key=GEMINI\_API\_KEY # Ensures the API key is used.  
)

# Agent: Planner

planner = Agent(  
role=“Content Planner”,  
goal=“Plan engaging and factually accurate content on {topic}”,  
backstory=(  
"You’re working on planning a blog article about the topic: {topic}. "  
"You collect information that helps the audience learn something and make informed decisions. "  
“Your work is the basis for the Content Writer to write an article on this topic.”  
),  
llm=llm,  
allow\_delegation=False,  
verbose=True  
)

# Agent: Writer

writer = Agent(  
role=“Content Writer”,  
goal=“Write an insightful and factually accurate opinion piece about the topic: {topic}”,  
backstory=(  
"You’re working on writing a new opinion piece about the topic: {topic}. "  
"You base your writing on the work of the Content Planner, who provides an outline and relevant context about the topic. "  
"You follow the main objectives and direction of the outline as provided by the Content Planner. "  
"You also provide objective and impartial insights and back them up with the information from the Content Planner. "  
“You acknowledge in your opinion piece when your statements are opinions as opposed to objective statements.”  
),  
llm=llm,  
allow\_delegation=False,  
verbose=True  
)

# Agent: Editor

editor = Agent(  
role=“Editor”,  
goal=“Edit a given blog post to align with the writing style of the organization.”,  
backstory=(  
"You are an editor who receives a blog post from the Content Writer. "  
"Your goal is to review the blog post to ensure that it follows journalistic best practices, "  
"provides balanced viewpoints when presenting opinions or assertions, "  
“and avoids major controversial topics when possible.”  
),  
llm=llm,  
allow\_delegation=False,  
verbose=True  
)

# Task: Plan

plan = Task(  
description=(  
“1. Prioritize the latest trends, key players, and noteworthy news on {topic}.\n”  
“2. Identify the target audience, considering their interests and pain points.\n”  
“3. Develop a detailed content outline including an introduction, key points, and a call to action.\n”  
“4. Include SEO keywords and relevant data or sources.”  
),  
expected\_output=(  
"A comprehensive content plan document with an outline, audience analysis, "  
“SEO keywords, and resources.”  
),  
agent=planner,  
)

# Task: Write

write = Task(  
description=(  
“1. Use the content plan to craft a compelling blog post on {topic}.\n”  
“2. Incorporate SEO keywords naturally.\n”  
“3. Ensure sections/subtitles are properly named in an engaging manner.\n”  
“4. Structure the post with an engaging introduction, insightful body, and a summarizing conclusion.\n”  
“5. Proofread for grammatical errors and ensure alignment with the brand’s voice.\n”  
),  
expected\_output=(  
"A well-written blog post in markdown format, ready for publication, "  
“with each section containing 2 or 3 paragraphs.”  
),  
agent=writer,  
)

# Task: Edit

edit = Task(  
description=(  
“Proofread the given blog post for grammatical errors and ensure it aligns with the brand’s voice.”  
),  
expected\_output=(  
"A well-edited blog post in markdown format, ready for publication, "  
“with each section containing 2 or 3 paragraphs.”  
),  
agent=editor,  
)

crew = Crew(  
agents=[planner, writer, editor],  
tasks=[plan, write, edit],  
verbose=True # Set verbose to 2 to see detailed logs during execution.  
)

from IPython.display import Markdown  
topic = “Indian Food” # Replace with any topic you want to explore  
result = crew.kickoff(inputs={“topic”: topic})  
Markdown(result)

**Here’s the load of error**

**Error Code:** `litellm.exceptions.APIConnectionError`

The error occurs when `litellm` attempts to retrieve credentials from Google Compute Engine’s metadata service but fails with a `404 Not Found` response. Specifically, the request to:

[http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true](http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true)

fails, causing authentication issues when trying to use Google Vertex AI via `litellm`.

Note: I am not trying to do anything with vertext, look at my code I am trying with API keys
