sub2api
sub2api copied to clipboard
Admin Panel: OpenAI API Key Connection Test uses incorrect endpoint (/responses instead of /v1/chat/completions)
Describe the bug
Currently, when testing connections for API Key type OpenAI accounts in the admin panel, the backend hardcodes the endpoint to /responses. For standard/custom OpenAI-compatible upstreams (e.g. One-API, New-API, or custom relays) that only expose /v1/chat/completions, this causes the connection test to fail with a 404 error or similar, even though normal chat completion routing works correctly.
To Reproduce
- Go to Admin Panel -> Account Management
- Add an OpenAI account, select type as
apikey - Set the upstream base URL to a standard compatible endpoint (e.g.,
https://api.openai.comor a custom one) - Click Test.
- The test fails because it sends the request to
<base_url>/responsesinstead of the standard/v1/chat/completions.
Expected behavior
The connection test for OpenAI apikey accounts should utilize the standard /v1/chat/completions endpoint to guarantee compatibility with all third-party providers and proxies.
Code Reference
Location: backend/internal/service/account_test_service.go
// backend/internal/service/account_test_service.go:469
baseURL := account.GetOpenAIBaseURL()
if baseURL == "" {
baseURL = "https://api.openai.com"
}
normalizedBaseURL, err := s.validateUpstreamBaseURL(baseURL)
// ...
apiURL = strings.TrimSuffix(normalizedBaseURL, "/") + "/responses"
暂无计划支持completions端点的上游