Crewai memory embedding locally with Ollama ERROR OPENAI_API_KEY SOLVED

Hello,

I faced a problem that many have faced as well and I did not find a solution online. Finally I fixed it and I thought it could be good to share the solution.

The setup I have is Crewai with local Ollama model AND memory embedding with local Ollama embedding. This gives an error of OPENAI_API_KEY not found. If I remove the memory and embedding, the local ollama model runs nicely.

I manage to fix the error if you declare the embedding in one line and keep the memory=True line independently, so like this:

ollama_embedder = {
“provider”: “ollama”,
“config”: {
“model”: “qwen3-embedding”,
“url”: “http://localhost:11434
}
}

my_crew = Crew(
agents=[
concept_architect,
scientific_validator,
editor
],
tasks=[
establish_premise,
validate_science,
refine_and_edit
],
memory=True,
embedder=ollama_embedder,
verbose=True,
)