Receiving 'openai.AuthenticationError' even though I am using Groq

Dear Phidata community,

I’ve recently ventured into Phidata slowly learning the nuances of how can make the most of this. I was trying to build an agentic rag. I am nowhere using OpenAI in my code but still this ‘openai.AuthenticationError’ gets triggered all of a sudden!

Here’s the code snippet:

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge_base=PDFUrlKnowledgeBase(
    urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
    vector_db=PgVector2(collection="recipies",db_url=db_url)
)

knowledge_base.load(recreate=True, upsert=True)
#knowledge_base.load()

storage=PgAssistantStorage(table_name="pdf-assistant",db_url=db_url)

agent = Agent(
    model=Groq(id="llama-3.3-70b-versatile"),
    knowledge=knowledge_base,
    storage=storage,
)

response: RunResponse = agent.run("What is the recipe for chicken curry?")
res = response.content

The error that I’m getting:

openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: GJUQLOdd************************************************************************************************************************************************uKYA. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

Hi @cipherunhsiv
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 48 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

Hi @cipherunhsiv

  1. I suggest using PgAgentStorage instead of PgAssistantStorage (it is deprecated). Also use PgVector instead of PgVector2 (also deprecated).
  2. When you use a VectorDB and you don’t specify a embedder, it uses the default OpenAIEmbedder to do embeddings, which requires the OpenAI API Key. See docs here for other embedders.

I don’t have access to OpenAI and can’t use OpenAIEmbedder. It will be better if you suggest some other open source equivalent which is actually working! I tried out around 5 embedder from the docs and nothing actually worked for me the way i wanted it to! It all triggered some random errors! Kindly assist me in this regards @Dirk

Hi
so you can use the ollama embedder which works with an open source model. The model used for generating embeddings needs to run locally. In this case it is openhermes so you have to install ollama and run ollama pull openhermes in your terminal.

If this doesn’t work, please inform me, because it should.

I think FastEmbed could help here - it’s a great open-source embedder that works with Phidata. I actually opened an issue about this that was just fixed, so make sure you’re on the latest version. FastEmbed Cookbook.