run-llama/llama_index · critical · ImportError
`llama-index-embeddings-openai` package not found, please ru
Error message
`llama-index-embeddings-openai` package not found, please run `pip install llama-index-embeddings-openai`
What it means
resolve_embed_model() falls back to OpenAIEmbedding when embed_model is None or the string 'default'. That requires the optional integration llama-index-embeddings-openai; since llama-index v0.10 the OpenAI integration is no longer a core dependency, so a bare install raises this ImportError telling you to install it.
Source
Thrown at llama-index-core/llama_index/core/embeddings/utils.py:60
if embed_model == "default":
if os.getenv("IS_TESTING"):
embed_model = MockEmbedding(embed_dim=8)
embed_model.callback_manager = callback_manager or Settings.callback_manager
return embed_model
try:
from llama_index.embeddings.openai import (
OpenAIEmbedding,
) # pants: no-infer-dep
from llama_index.embeddings.openai.utils import (
validate_openai_api_key,
) # pants: no-infer-dep
embed_model = OpenAIEmbedding()
validate_openai_api_key(embed_model.api_key) # type: ignore
except ImportError:
raise ImportError(
"`llama-index-embeddings-openai` package not found, "
"please run `pip install llama-index-embeddings-openai`"
)
except ValueError as e:
raise ValueError(
"\n******\n"
"Could not load OpenAI embedding model. "
"If you intended to use OpenAI, please check your OPENAI_API_KEY.\n"
"Original error:\n"
f"{e!s}"
"\nConsider using embed_model='local'.\n"
"Visit our documentation for more embedding options: "
"https://developers.llamaindex.ai/python/framework/module_guides/"
"models/embeddings/"
"\n******"
)
# for image multi-modal embeddings
elif isinstance(embed_model, str) and embed_model.startswith("clip"):View on GitHub (pinned to afd0fef371)
Solutions
- pip install llama-index-embeddings-openai (or the meta-package pip install llama-index)
- Or run fully offline: pass embed_model='local:BAAI/bge-small-en-v1.5' with llama-index-embeddings-huggingface installed
- Or pass any explicit BaseEmbedding instance (e.g. HuggingFaceEmbedding) so the OpenAI default is never reached
Example fix
// before index = VectorStoreIndex.from_documents(docs) # ImportError: package not found // after # pip install llama-index-embeddings-openai index = VectorStoreIndex.from_documents(docs) # or offline: # pip install llama-index-embeddings-huggingface index = VectorStoreIndex.from_documents(docs, embed_model="local:BAAI/bge-small-en-v1.5")
Defensive patterns
Strategy: fallback
Validate before calling
try:
import llama_index.embeddings.openai # noqa: F401
has_openai = True
except ImportError:
has_openai = False
if not has_openai and embed_model is None:
embed_model = "local:BAAI/bge-small-en-v1.5" # explicit, no default surprise Try / catch
try:
index = VectorStoreIndex.from_documents(docs)
except ImportError as e:
if "llama-index-embeddings-openai" in str(e):
raise RuntimeError("pip install llama-index-embeddings-openai or set embed_model") from e
raise Prevention
- Always pass an explicit embed_model instead of relying on the OpenAI default
- Pin integration extras in requirements: llama-index-embeddings-openai==<ver>
- Fail fast at startup by importing the embedding integration in your bootstrap code
When it happens
Trigger: Constructing any index/retriever (VectorStoreIndex.from_documents(...)) without an embed_model argument on an environment where llama-index-embeddings-openai is not installed; a fresh pip install llama-index-core only.
Common situations: Installing the modular llama-index post-0.10 without integration extras; CI or Docker images slimmed to core only; upgrading from llama_index<=0.9 (bundled OpenAI) to the split packages.
Related errors
- `llama-index-embeddings-clip` package not found, please run
- `llama-index-embeddings-huggingface` package not found, plea
- `llama-index-embeddings-langchain` package not found, please
- Invalid Embedding name: {name}
- ****** Could not load OpenAI embedding model. If you intend
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/955720201afaa04f.
Report an issue: GitHub.