Skip to content

Commit dafc90b

Browse files
fix: codex api wiring mode
1 parent 04ab464 commit dafc90b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

core/framework/llm/litellm.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,17 @@ def __init__(
558558
"LiteLLM is not installed. Please install it with: uv pip install litellm"
559559
)
560560

561+
# The Codex ChatGPT backend is a Responses API endpoint at
562+
# chatgpt.com/backend-api/codex/responses. LiteLLM's model registry
563+
# marks legacy codex models (gpt-5.3-codex) with mode="responses",
564+
# but newer models like gpt-5.4 default to mode="chat". Force
565+
# mode="responses" so litellm routes through the responses_api_bridge.
566+
if self._codex_backend and litellm is not None:
567+
_strip = self.model.removeprefix("openai/")
568+
_entry = litellm.model_cost.get(_strip, {})
569+
if _entry.get("mode") != "responses":
570+
litellm.model_cost.setdefault(_strip, {})
571+
litellm.model_cost[_strip]["mode"] = "responses"
561572
@staticmethod
562573
def _default_api_base_for_model(model: str) -> str | None:
563574
"""Return provider-specific default API base when required."""

0 commit comments

Comments
 (0)