sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

Admin Panel: OpenAI API Key Connection Test uses incorrect endpoint (/responses instead of /v1/chat/completions)

Open imleoo opened this issue 8 months ago • 1 comments

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

  1. Go to Admin Panel -> Account Management
  2. Add an OpenAI account, select type as apikey
  3. Set the upstream base URL to a standard compatible endpoint (e.g., https://api.openai.com or a custom one)
  4. Click Test.
  5. The test fails because it sends the request to <base_url>/responses instead 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"

imleoo avatar Mar 15 '26 03:03 imleoo

暂无计划支持completions端点的上游

Wei-Shaw avatar Mar 15 '26 08:03 Wei-Shaw