fix(web): use stored API key when fetching models for saved providers (#2910)

When editing an existing model, the edit form initializes apiKey as
empty for security. This caused "Fetch Available Models" to reject with
"please enter API Key first" even though the key is saved server-side.

Add model_index support: the frontend passes the model's index to the
backend, which looks up the stored key from config. The key never leaves
the backend. Provider and API base are validated to prevent a stored key
from being sent to an unrelated endpoint.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
GuoguoandClaude Opus 4.7 authored and GitHub committed 2026-05-21 15:51:45 +08:00
1 parent e7e21df354
commit 30938df40b
5 files changed
+153 -9

No files matched your search

+1
View File
@@ -167,6 +167,7 @@ export interface FetchModelsRequest {
provider: string
api_key?: string
api_base?: string
model_index?: number
}
export interface FetchModelsResponse {