VectifyAI/PageIndex · error · PageIndexAPIError
api_key is an empty string. Pass a real PageIndex API key fo
Error message
api_key is an empty string. Pass a real PageIndex API key for cloud mode, or omit api_key entirely for local mode.
What it means
api_key was passed as the empty string. An empty string is neither a valid cloud key nor the absence of a key (which selects local mode), so the SDK rejects it rather than silently doing the wrong thing.
Source
Thrown at pageindex/client.py:355
def __init__(
self,
api_key: Optional[str] = None,
*,
index: Optional[Union[Mapping[str, Any], str]] = None,
chat: Optional[Union[Mapping[str, Any], str]] = None,
mode: Optional[str] = None,
index_model: Optional[str] = None,
chat_model: Optional[str] = None,
model: Optional[str] = None,
summary_model: Optional[str] = None,
retrieve_model: Optional[str] = None,
storage_path: Optional[Union[str, os.PathLike[str]]] = None,
index_backend: Optional[dict[str, Any]] = None,
chat_backend: Optional[dict[str, Any]] = None,
):
if api_key == "":
raise PageIndexAPIError(
"api_key is an empty string. Pass a real PageIndex API key for "
"cloud mode, or omit api_key entirely for local mode."
)
# Each side picks one spelling — its slot, or the flat arguments.
# ``model`` sets every role, so it claims both sides.
index_flat: dict[str, Any] = {
name: value for name, value in
(("api_key", api_key),
("index_model", index_model),
("summary_model", summary_model),
("index_backend", index_backend),
("storage_path", storage_path), ("model", model))
if value is not None}
chat_flat: dict[str, Any] = {
name: value for name, value in
(("chat_model", chat_model),
("retrieve_model", retrieve_model),
("chat_backend", chat_backend), ("model", model))View on GitHub (pinned to afb5e11976)
Solutions
- Set a real PageIndex API key in the environment/export
- Use os.getenv("PAGEINDEX_API_KEY") (returns None when unset) instead of .get(..., "") so local mode is chosen by omission
- If local mode is intended, remove the api_key argument entirely
Example fix
# before
client = PageIndexClient(api_key=os.environ.get("PAGEINDEX_API_KEY", ""))
# after
client = PageIndexClient(api_key=os.environ.get("PAGEINDEX_API_KEY")) Defensive patterns
Strategy: validation
Validate before calling
api_key = os.getenv("PAGEINDEX_API_KEY")
if api_key == "":
api_key = None
client = PageIndexClient(api_key=api_key) Type guard
def valid_api_key(k) -> bool:
return k is None or (isinstance(k, str) and k != "") Prevention
- Use os.getenv() without a "" default so unset becomes None
- Fail fast at startup with a clear message when a key variable exists but is empty
When it happens
Trigger: PageIndexClient(api_key=""), or api_key=os.getenv("PAGEINDEX_API_KEY") when the variable is set to empty or unset and defaults to "".
Common situations: CI environments where a secrets variable exists but is empty; shell scripts exporting API_KEY=; defensive .get(key, "") patterns.
Related errors
- chat is an empty string — pass a model name, or "cloud" for
- chat is an empty dict — chat takes "model" and "backend" (yo
- Unknown chat keys ({keys}) — chat takes "model" and "backend
- chat declares mode "cloud" but carries ({keys}) — the manage
- chat must be a string or a dict.
AI-assisted analysis of VectifyAI/PageIndex@afb5e11976 (2026-08-27).
Data as JSON: /api/errors/aa45d8a7ce47be02.
Report an issue: GitHub.