VectifyAI/PageIndex · warning · FutureWarning
CHATGPT_API_KEY is deprecated — set OPENAI_API_KEY instead.
Error message
CHATGPT_API_KEY is deprecated — set OPENAI_API_KEY instead.
What it means
Module-level FutureWarning: if OPENAI_API_KEY is unset but the legacy CHATGPT_API_KEY is set, the latter is copied into OPENAI_API_KEY so requests still authenticate. It exists for backward compatibility with older ChatGPT-key deployments.
Source
Thrown at pageindex/utils.py:64
pass # best-effort: a failed repair leaves litellm's own error
def _mute_litellm_bridge_usage_warning() -> None:
"""litellm's chat→Responses bridge (e.g. OpenAI gpt-5.4+ with function
tools) logs a chat-shaped usage dict inside a ResponseAPIUsage field
(litellm_logging._get_assembled_streaming_response, 1.97–1.98), and
pydantic reports it on every streamed turn. Hide exactly that message;
every other warning still surfaces."""
import warnings
warnings.filterwarnings(
"ignore",
message=r"Pydantic serializer warnings:\s+"
r"(PydanticSerializationUnexpectedValue\()?Expected `ResponseAPIUsage`")
# Backward compatibility: support CHATGPT_API_KEY as alias for OPENAI_API_KEY
if not os.getenv("OPENAI_API_KEY") and os.getenv("CHATGPT_API_KEY"):
import warnings
warnings.warn("CHATGPT_API_KEY is deprecated — set OPENAI_API_KEY "
"instead.", FutureWarning)
os.environ["OPENAI_API_KEY"] = os.getenv("CHATGPT_API_KEY")
def count_tokens(text, model=None):
if not text:
return 0
import litellm
return litellm.token_counter(model=model, text=text)
def _strip_prefix(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
return s
def run_off_loop(func, *args):
"""Run func now, or on a worker thread when this thread already runs anView on GitHub (pinned to afb5e11976)
Solutions
- Rename the env var: export OPENAI_API_KEY=<same value> and remove CHATGPT_API_KEY from .env/CI secrets
- Reload the shell/session so the old var is gone
- Filter FutureWarning only temporarily if you cannot change the environment yet
Example fix
# before (.env) CHATGPT_API_KEY=sk-... # after (.env) OPENAI_API_KEY=sk-...
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv('OPENAI_API_KEY') and os.getenv('CHATGPT_API_KEY'):
os.environ['OPENAI_API_KEY'] = os.environ.pop('CHATGPT_API_KEY')
# import pageindex afterwards Try / catch
import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', FutureWarning)
import pageindex # legacy env still works, warning silenced Prevention
- Use OPENAI_API_KEY everywhere; delete CHATGPT_API_KEY from CI secrets and .env files
- Audit container images and shells for stale exported variables
- Fail CI on FutureWarnings to catch legacy env usage
When it happens
Trigger: Importing pageindex.utils in an environment that only defines CHATGPT_API_KEY (no OPENAI_API_KEY) — commonly a leftover from older scripts or CI secrets named the old way.
Common situations: CI/CD secrets or .env files created before the rename; shared containers where the old var leaks in; team conventions stuck on the legacy name.
Related errors
- The OpenAI backend is not configured: {exc}
- The Anthropic backend is not configured: set the ANTHROPIC_A
- api_key is an empty string. Pass a real PageIndex API key fo
- optimize_expand is deprecated: pass optimize='full', 'merge'
AI-assisted analysis of VectifyAI/PageIndex@afb5e11976 (2026-08-27).
Data as JSON: /api/errors/ac852056c10a30e2.
Report an issue: GitHub.