Gemini has stopped working again!

I am running the following code in Google Colab

pip install crewai
pip install crewai_tools

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

GEMINI_API_KEY=...

from crewai import LLM
llm = LLM(
    model="gemini/gemini-1.5-pro",
    api_key=GEMINI_API_KEY,
    temperature=0.7
)
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
)
writer = Agent(
...
)
editor = Agent(
...
)
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,
)
write = Task(
...
)
edit = Task(
...
)
crew = Crew(
    agents=[planner, writer, editor],
    tasks=[plan, write, edit],
    verbose=True
)
result = crew.kickoff(inputs={"topic": "Artificial Intelligence"})

A long list of errors starting with

# Agent: Content Planner
## Task: 1. Prioritize the latest trends, key players, and noteworthy news on Artificial Intelligence.
2. Identify the target audience, considering their interests and pain points.
3. Develop a detailed content outline including an introduction, key points, and a call to action.
4. Include SEO keywords and relevant data or sources.
ERROR:root: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
ERROR:root: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
ERROR:root: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: Content Planner
## Final Answer: 
## Content Plan: Demystifying Artificial Intelligence: A Practical Guide to the Future

**Target Audience:** Business professionals, tech enthusiasts, students, and anyone curious about AI's impact on their lives and the future.  They are interested in understanding AI's potential benefits and challenges, seeking practical applications, and wanting to stay informed about the latest developments. Pain points include fear of job displacement, lack of understanding of complex concepts, and difficulty separating hype from reality.

**SEO Keywords:** Artificial Intelligence, AI, Machine Learning, Deep Learning, AI applications, AI trends, AI future, AI ethics, AI in business, AI in healthcare, AI in education.

**Content Outline:**

**I. Introduction (Hook)**
   * Start with a captivating statement or question about AI's growing influence.
   * Briefly define AI and its various subfields (machine learning, deep learning, etc.) in accessible terms.
   * Briefly outline the article's purpose: to provide a clear and concise overview of AI's current state and future potential.

**II.  Current Trends in AI**
   * **Generative AI:** Explain the rise of tools like ChatGPT, DALL-E 2, and Midjourney, emphasizing their creative potential and practical applications. Include examples and real-world use cases.
   * **AI in Automation:** Discuss how AI is automating tasks across industries, from manufacturing and logistics to customer service and data analysis. Address potential concerns about job displacement and the changing nature of work.
   * **Explainable AI (XAI):** Highlight the importance of transparency and understanding how AI decisions are made.  Discuss the ethical implications and the need for accountability.
   * **Edge AI:**  Explain how AI is moving from the cloud to the edge, enabling faster processing and reduced latency in devices like smartphones and IoT sensors. Provide examples of edge AI applications.

**III. Key Players in the AI Landscape**
   * Briefly profile leading companies driving AI innovation (e.g., Google, Microsoft, OpenAI, Amazon, etc.).  Focus on their key contributions and areas of expertise.
   * Mention influential researchers and thought leaders shaping the field of AI.

**IV. Noteworthy News and Recent Breakthroughs**
   * Highlight recent advancements in AI research, such as new algorithms, breakthroughs in natural language processing, or advancements in computer vision.
   * Discuss any significant news or policy developments related to AI regulation and ethical considerations.

**V.  The Future of AI: Opportunities and Challenges**
   * Explore the potential impact of AI on various sectors (healthcare, finance, education, transportation, etc.).  
   * Discuss the ethical dilemmas surrounding AI development, including bias, privacy, and job displacement.
   * Offer balanced perspectives, acknowledging both the exciting possibilities and potential risks of AI.

**VI.  Practical Applications of AI (Real-world Examples)**
   * Showcase how AI is already being used in everyday life, from personalized recommendations and virtual assistants to fraud detection and medical diagnosis.
   * Include compelling examples and case studies to illustrate the tangible benefits of AI.

**VII. Getting Started with AI: Resources and Tools**
   * Provide links to educational resources, online courses, and tools for those interested in learning more about AI.
   * Suggest ways for readers to engage with the AI community and stay up-to-date on the latest developments.

**VIII. Conclusion (Call to Action)**
   * Summarize the key takeaways about AI's current state and future potential.
   * Encourage readers to share their thoughts and questions in the comments section.
   *  Invite readers to subscribe to the blog or follow social media channels for future updates on AI.


**Resources/Data Sources:**
* Reports and publications from reputable organizations like McKinsey, Gartner, and the World Economic Forum.
* Research papers from leading universities and AI labs.
* News articles from credible sources (e.g., The Verge, Wired, MIT Technology Review).
* Websites and blogs of prominent AI companies.



This comprehensive plan ensures the article is engaging, informative, and optimized for search engines, attracting the target audience and establishing the blog as a valuable resource for AI-related information.


# Agent: Content Writer
## Task: 1. Use the content plan to craft a compelling blog post on Artificial Intelligence.
2. Incorporate SEO keywords naturally.
3. Sections/Subtitles are properly named in an engaging manner.
4. Ensure the post is structured with an engaging introduction, insightful body, and a summarizing conclusion.
5. Proofread for grammatical errors and alignment with the brand's voice.



LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

# Agent: Content Writer
## Task: 1. Use the content plan to craft a compelling blog post on Artificial Intelligence.
2. Incorporate SEO keywords naturally.
3. Sections/Subtitles are properly named in an engaging manner.
4. Ensure the post is structured with an engaging introduction, insightful body, and a summarizing conclusion.
5. Proofread for grammatical errors and alignment with the brand's voice.



LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

# Agent: Content Writer
## Task: 1. Use the content plan to craft a compelling blog post on Artificial Intelligence.
2. Incorporate SEO keywords naturally.
3. Sections/Subtitles are properly named in an engaging manner.
4. Ensure the post is structured with an engaging introduction, insightful body, and a summarizing conclusion.
5. Proofread for grammatical errors and alignment with the brand's voice.



LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

---------------------------------------------------------------------------
OpenAIError                               Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/litellm/llms/openai/openai.py in completion(self, model_response, timeout, optional_params, litellm_params, logging_obj, model, messages, print_verbose, api_key, api_base, acompletion, logger_fn, headers, custom_prompt_dict, client, organization, custom_llm_provider, drop_params)
    638                     else:
--> 639                         raise e
    640         except OpenAIError as e:

58 frames
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:

OpenAIError                               Traceback (most recent call last)
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:

AuthenticationError                       Traceback (most recent call last)
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:

OpenAIError                               Traceback (most recent call last)
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:

OpenAIError                               Traceback (most recent call last)
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:

AuthenticationError                       Traceback (most recent call last)
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:

OpenAIError                               Traceback (most recent call last)
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:

OpenAIError                               Traceback (most recent call last)
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:

AuthenticationError                       Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/litellm/litellm_core_utils/exception_mapping_utils.py in exception_type(model, original_exception, custom_llm_provider, completion_kwargs, extra_kwargs)
    310                 ):
    311                     exception_mapping_worked = True
--> 312                     raise AuthenticationError(
    313                         message=f"AuthenticationError: {exception_provider} - {message}",
    314                         llm_provider=custom_llm_provider,

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

In my case am trying to setup a Crew and trying to leverage PDFSearchTool using gemini as LLM. Even after the PDFSearchTool was setup, am still getting the OpenAI error. I assume that this is a bug and the default setting in Crew AI is pointing to OpenAI. Even after setting Google API key, am getting similar error.

This topic was automatically closed after 30 days. New replies are no longer allowed.