TL;DR
Enabling memory=True on a Crew triggers a Pydantic ValidationError when an OpenAI API key is absent because CrewAI’s embedder parameter defaults to {“provider”: “openai”}.
Issue #2943 was reported on crewAI 0.121.0 and has since been closed as completed, with a linked commit titled “Fix ValidationError when using memory=True without OpenAI API key”. The sources do not say whether newer releases still reproduce it, but the OpenAI default for memory embeddings is documented across versions, so a missing key or custom embedder is the first thing to check.
Other OpenAI-related failures, such as knowledge sources or agent and manager LLMs, are separate problems with separate fixes. Setting a Crew embedder does not resolve those.
For the memory error, either set the OPENAI_API_KEY environment variable or pass an explicit custom embedder configuration (such as Ollama).
The Symptom: Pydantic ValidationError on Crew Initialization with memory=True
In issue #2943 submitted to the CrewAI repository, a developer reported an error when adding the parameter memory=True to a Crew. While the setup executed without issue with cache=True, enabling memory=True immediately triggered a validation error.
The issue occurred during Crew instantiation:
synergistic_crew = Crew(
agents=[holiday_agent, macro_agent, news_summarizer_agent, analysis_forecast_agent, user_query_agent],
tasks=[holiday_task, macro_task, news_summarizer_task, analysis_forecast_task, user_query_task],
process=Process.sequential,
verbose=True,
cache=True,
memory=True
)
Adding memory=True produced the following Pydantic validation failure:
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew
Value error, Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keys [type=value_error, input_value={'agents': [Agent(role=Ho...': True, 'memory': True}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.11/v/value_error
The issue report listed the environment as Ubuntu 20.04, Python 3.10, Venv, crewAI version 0.121.0, and crewAI Tools version 0.45.0. Although the reporter noted using “pydantic version V1”, the traceback references pydantic_core and links to https://errors.pydantic.dev/2.11/v/value_error, indicating that Pydantic v2.11 was actively running in the runtime environment.
The issue was later closed as completed on 2025-06-04, with a linked commit titled “Fix ValidationError when using memory=True without OpenAI API key”. The thread does not state which release contains the fix, so check your installed version and its changelog before assuming you will see the exact same error today.
Sources: error-pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew
Why the Error Triggers: Pydantic Validators and OpenAI Default Fallbacks
CrewAI relies on Pydantic to validate configuration parameters and dependencies when instantiating objects like Crew, Agent, and Task. When memory=True is set on a Crew, CrewAI initializes its memory system, which requires an embedding model to convert text into vector representations. According to the Crews documentation (v1.15.28), the embedder attribute on Crew defaults to {“provider”: “openai”}.
In issue #2943 on 0.121.0, enabling memory without an alternative embedder and without an OpenAI key produced a validation error whose message asks for an OpenAI API key. The sources do not show exactly where in the Crew validators the check runs, but the traceback shows it surfacing as a Pydantic error during Crew construction:
ValidationError: 1 validation error for Crew Value error, Please provide an OpenAI API key
Versions matter here. The issue was filed on crewAI 0.121.0, the Crew attribute descriptions in this article come from the v1.15.28 docs, and the unified Memory class comes from the “edge” docs. The Crews docs describe memory in terms of short-term, long-term, and entity memory, while the edge docs describe a single unified Memory class. In both, the documented default embedder is OpenAI. Where a behavior comes from only one of these sources, the text below says so.
Other parts of CrewAI also involve OpenAI by default or require explicit configuration. They fail at different points and have different fixes:
- Memory Embeddings: Directly tied to Crew initialization when memory=True, triggering the reported validation error if embedder remains at its OpenAI default.
- Agent LLMs: The “Connect to any LLM” documentation covers configuring a non-OpenAI model per agent. The fix is setting the llm parameter on the Agent, not the Crew embedder.
- Hierarchical Process Coordination: When setting process=Process.hierarchical, the Crews documentation specifies that manager_llm or manager_agent is required. Supply one of them. The embedder setting does not affect this.
- Knowledge Sources: Issue #2164 reports a separate “Invalid Knowledge Configuration: Please provide an OpenAI API key” error for agent knowledge. It is a different error message from the memory one, so check that issue for its own fix.
Sources: error-pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew · Issue #2943 · crewAIInc/crew, [BUG] Agent knowledge – Invalid Knowledge Configuration: Please provide an OpenAI API key. · Issue #2164 · cre, Crews – CrewAI, Memory – CrewAI, Connect to any LLM – CrewAI
Inspecting Crew Attributes and Execution Flow Defaults
The Crew attributes below come from the v1.15.28 Crews documentation. In issue #2943, the same crew ran with cache=True but failed once memory=True was added:
- embedder: Configuration dictionary for the embedding provider used by the crew. It is primarily utilized by memory and defaults to {“provider”: “openai”}.
- memory: Toggles memory systems (short-term, long-term, entity memory in earlier documentation; unified Memory in newer releases). It defaults to False.
- cache: Toggles caching, defaulting to True.
- process: Execution flow strategy, defaulting to Process.sequential. When set to Process.hierarchical, manager_llm or manager_agent is required.
- verbose: Controls logging verbosity, defaulting to False.
- max_rpm: Maximum requests per minute, defaulting to None.
The embedder attribute is described as primarily used by memory and defaults to {“provider”: “openai”}. The reporter’s crew had cache=True throughout and the error appeared only after memory=True was added, which points at the memory setting. The sources do not explain why cache=True was unaffected, so treat any explanation of that as an inference.
Sources: Crews – CrewAI
The Underlying Culprit: CrewAI Unified Memory and Embedding Requirements
In newer releases of CrewAI (as outlined in the edge documentation), the framework consolidates memory handling into a unified Memory class. When memory=True is passed, the crew creates a default Memory() instance and passes through the crew’s embedder setting.
In this unified system, memory recall ranks results using composite scoring:
composite = semantic_weight * similarity + recency_weight * decay + importance_weight * importance
where similarity is computed from vector distances:
similarity = 1 / (1 + distance)
According to the official documentation, without an explicit embedder configuration, Memory uses OpenAI text-embedding-3-large embeddings to power these vector calculations. When memories are saved, an LLM also infers scope, categories, and importance scores.
To resolve the ValidationError, developers have two options depending on their architecture:
Option 1: Providing the OpenAI API Key
If you plan to use OpenAI models or embeddings, supply the key as an environment variable before initializing your crew (ideally via a .env file or your shell environment):
import os
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
Option 2: Configuring a Custom Embedder (Non-OpenAI Setup)
If you run local or alternative models (such as Ollama) and do not want to use OpenAI, configure a custom embedder. The Crews docs list embedder as a Crew attribute, so the example below passes it to Crew. The edge Memory docs show the same kind of embedder configuration on a Memory(embedder=…) instance, with the Ollama model key named “model_name”. Check which form your installed version accepts:
from crewai import Crew, Process
crew = Crew(
agents=[research_agent, writer_agent],
tasks=[research_task, write_task],
process=Process.sequential,
memory=True,
embedder={
"provider": "ollama",
"config": {
"model_name": "mxbai-embed-large",
"url": "http://localhost:11434/api/embeddings"
}
}
)
Explicitly declaring the embedder replaces the {“provider”: “openai”} default. This addresses the memory embedding error only. It does not change the llm setting on agents or manager_llm.
Sources: Memory – CrewAI
Closing thoughts
Convenience flags like memory=True simplify multi-agent workflows, but they often carry implicit dependencies on default cloud providers. In CrewAI, enabling memory activates embedding operations that default to OpenAI unless overridden.
When building workflows with alternative providers or local models, actively specifying configuration parameters—such as setting a custom embedder or defining model providers explicitly—prevents unexpected Pydantic validation errors during crew initialization.
Frequently Asked Questions
Why does setting memory=True trigger a validation error requesting an OpenAI API key?
Enabling memory=True activates CrewAI’s memory system, which requires an embedding model for vector storage and retrieval. Because the embedder parameter defaults to {“provider”: “openai”}, Crew initialization raises a Pydantic ValidationError if OPENAI_API_KEY is not found in the environment.
What default embedding model does CrewAI use for its memory system?
The embedder parameter defaults to {“provider”: “openai”}. In CrewAI’s unified Memory documentation, the default embedding model is specified as OpenAI text-embedding-3-large.
How can you resolve this error without an OpenAI API key?
You can provide a custom embedder dictionary to the Crew, such as using provider ollama with an embedding model like mxbai-embed-large, or set the OPENAI_API_KEY environment variable. Check which embedder form your installed version accepts.
Why did cache=True work in issue #2943 while memory=True failed?
In the issue, the reporter’s crew with cache=True ran, and the error appeared only after memory=True was added. The sources do not give a reason for the difference. The Crews docs describe embedder as primarily used by memory, which is consistent with the error following memory=True.
Keep reading: LLM Agents & Tooling
- Troubleshooting ChromaDB InvalidDimensionException: Resolving the 1536 vs 384 Dimension Mismatch — Fix ChromaDB InvalidDimensionException where embedding dimension 1536 does not match collection dimensionality 384 by explicitly setting the…
- Troubleshooting LangGraph InvalidUpdateError: Resolving Concurrent State Updates with Annotated Reducers — Fix langgraph.errors.InvalidUpdateError in LangGraph. Learn how to resolve concurrent state write collisions using Annotated keys and reducer…
- Troubleshooting LangChain OutputParserException: Both Final Answer and Parse-able Action Produced — Resolve LangChain’s OutputParserException caused when a ReAct agent outputs both an action and final answer. Learn the root causes and best fixes.
- Resolving Pydantic State Deserialization Failures in LangGraph Checkpointers — Pydantic state turning into a raw dict in LangGraph checkpoints? Four causes: msgpack allowlist, unimportable classes, schema drift, unserializable…
All guides in this series: LLM Agent Guides: LangChain, LangGraph & AI Tooling









