fix: use Responses API for Copilot models that don't support chat/completions

gpt-5.4, gpt-5.4-mini, and codex variants only support /responses,
not /chat/completions on the Copilot endpoint. Auto-detect and set
use_responses_api=True for these models.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Jiaxu Liu 2026-03-23 13:50:55 +00:00
parent d8ac212253
commit 24e97fb703
1 changed files with 18 additions and 0 deletions

View File

@ -36,6 +36,19 @@ _PROVIDER_CONFIG = {
}
# Models that only support the Responses API on the Copilot endpoint.
_COPILOT_RESPONSES_ONLY = frozenset((
"gpt-5.4", "gpt-5.4-mini",
"gpt-5.3-codex", "gpt-5.2-codex",
"gpt-5.1-codex", "gpt-5.1-codex-mini", "gpt-5.1-codex-max",
))
def _copilot_needs_responses_api(model: str) -> bool:
"""Return True if the model requires /responses instead of /chat/completions."""
return model in _COPILOT_RESPONSES_ONLY
class OpenAIClient(BaseLLMClient):
"""Client for OpenAI, Ollama, OpenRouter, xAI, and GitHub Copilot providers.
@ -97,6 +110,11 @@ class OpenAIClient(BaseLLMClient):
if codex_token:
llm_kwargs["api_key"] = codex_token
# Copilot: newer models (gpt-5.4, codex variants) only support the
# Responses API (/responses), not Chat Completions (/chat/completions).
if self.provider == "copilot" and _copilot_needs_responses_api(self.model):
llm_kwargs["use_responses_api"] = True
return NormalizedChatOpenAI(**llm_kwargs)
def validate_model(self) -> bool: