docs(providers): clarify responses routing behavior

This commit is contained in:
Equent 2026-04-02 22:01:30 +08:00
parent c1d0b37675
commit 588539f3c2
2 changed files with 15 additions and 3 deletions

View file

@ -91,6 +91,10 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err
if apiBase == "" { if apiBase == "" {
apiBase = getDefaultAPIBase(protocol) apiBase = getDefaultAPIBase(protocol)
} }
// OpenAI is the protocol where /responses is expected to work natively.
// The shared openai_compat transport still keeps /chat/completions as the
// compatibility path, but gpt-5-family models will probe /responses
// first before falling back when necessary.
return NewHTTPProviderWithMaxTokensFieldAndRequestTimeout( return NewHTTPProviderWithMaxTokensFieldAndRequestTimeout(
cfg.APIKey(), cfg.APIKey(),
apiBase, apiBase,
@ -159,7 +163,12 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err
"vivgrid", "volcengine", "vllm", "qwen", "qwen-intl", "qwen-international", "dashscope-intl", "vivgrid", "volcengine", "vllm", "qwen", "qwen-intl", "qwen-international", "dashscope-intl",
"qwen-us", "dashscope-us", "mistral", "avian", "longcat", "modelscope", "novita", "qwen-us", "dashscope-us", "mistral", "avian", "longcat", "modelscope", "novita",
"coding-plan", "alibaba-coding", "qwen-coding", "mimo": "coding-plan", "alibaba-coding", "qwen-coding", "mimo":
// All other OpenAI-compatible HTTP providers // All other OpenAI-compatible HTTP providers.
// These providers generally remain /chat/completions-first in practice,
// even though they share the same transport/parser wrapper. If one of
// these gateways exposes a gpt-5-family model ID, openai_compat may probe
// /responses once and then fall back automatically when the endpoint does
// not support it.
if cfg.APIKey() == "" && cfg.APIBase == "" { if cfg.APIKey() == "" && cfg.APIBase == "" {
return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol) return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol)
} }

View file

@ -172,8 +172,11 @@ func shouldPreferResponses(rawModel, normalizedModel string) bool {
normalizedModel = strings.ToLower(strings.TrimSpace(normalizedModel)) normalizedModel = strings.ToLower(strings.TrimSpace(normalizedModel))
// Keep the automatic route conservative: only gpt-5 models are forced // Keep the automatic route conservative: only gpt-5 models are forced
// onto /responses, and all other model families stay on chat/completions // onto /responses today, and all other model families stay on
// unless they are explicitly routed elsewhere by the caller. // /chat/completions unless they are explicitly routed elsewhere by the
// caller. When OpenAI ships another Responses-first family (for example,
// gpt-6), update this gate at the same time so new native models do not
// silently stay on the compatibility path.
return strings.HasPrefix(rawModel, "gpt-5") || strings.HasPrefix(normalizedModel, "gpt-5") return strings.HasPrefix(rawModel, "gpt-5") || strings.HasPrefix(normalizedModel, "gpt-5")
} }