mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-08 01:16:47 +08:00
- Introduced `xai-api-key` to configuration for supporting xAI provider integration. - Added API key operations: creation, updates, deletion, and sanitization. - Implemented backend enhancements for credential-specific routing, response filtering with model aliasing, and WebSocket handling for xAI services. - Included extensive test coverage to validate configuration parsing, CRUD operations, and the new functionalities. - Updated related modules to handle `xai-api-key`, including the watcher, management handlers, and configuration sanitizers.
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package cliproxy
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v7/internal/watcher"
|
|
"github.com/router-for-me/CLIProxyAPI/v7/sdk/config"
|
|
)
|
|
|
|
// NewFileTokenClientProvider returns the default token-backed client loader.
|
|
func NewFileTokenClientProvider() TokenClientProvider {
|
|
return &fileTokenClientProvider{}
|
|
}
|
|
|
|
type fileTokenClientProvider struct{}
|
|
|
|
func (p *fileTokenClientProvider) Load(ctx context.Context, cfg *config.Config) (*TokenClientResult, error) {
|
|
// Stateless executors handle tokens
|
|
_ = ctx
|
|
_ = cfg
|
|
return &TokenClientResult{SuccessfulAuthed: 0}, nil
|
|
}
|
|
|
|
// NewAPIKeyClientProvider returns the default API key client loader that reuses existing logic.
|
|
func NewAPIKeyClientProvider() APIKeyClientProvider {
|
|
return &apiKeyClientProvider{}
|
|
}
|
|
|
|
type apiKeyClientProvider struct{}
|
|
|
|
func (p *apiKeyClientProvider) Load(ctx context.Context, cfg *config.Config) (*APIKeyClientResult, error) {
|
|
geminiCount, vertexCompatCount, claudeCount, codexCount, xaiCount, openAICompat := watcher.BuildAPIKeyClients(cfg)
|
|
if ctx != nil {
|
|
select {
|
|
case <-ctx.Done():
|
|
return nil, ctx.Err()
|
|
default:
|
|
}
|
|
}
|
|
return &APIKeyClientResult{
|
|
GeminiKeyCount: geminiCount,
|
|
VertexCompatKeyCount: vertexCompatCount,
|
|
ClaudeKeyCount: claudeCount,
|
|
CodexKeyCount: codexCount,
|
|
XAIKeyCount: xaiCount,
|
|
OpenAICompatCount: openAICompat,
|
|
}, nil
|
|
}
|