mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
Fixed bug #38
Add support for API key indexing in OpenAI compatibility clients - Updated `NewOpenAICompatibilityClient` to accept `apiKeyIndex` for managing multiple API keys. - Modified client instantiation loops to initialize one client per API key. - Adjusted client ID format to include `apiKeyIndex` for unique identification. - Removed API key rotation logic within `GetCurrentAPIKey`. - Updated `.gitignore` to include `AGENTS.md`.
This commit is contained in:
@@ -335,14 +335,16 @@ func buildAPIKeyClients(cfg *config.Config) (map[string]interfaces.Client, int,
|
||||
|
||||
if len(cfg.OpenAICompatibility) > 0 {
|
||||
for _, compatConfig := range cfg.OpenAICompatibility {
|
||||
log.Debugf("Initializing OpenAI compatibility client for provider: %s", compatConfig.Name)
|
||||
compatClient, errClient := client.NewOpenAICompatibilityClient(cfg, &compatConfig)
|
||||
if errClient != nil {
|
||||
log.Errorf("failed to create OpenAI compatibility client for %s: %v", compatConfig.Name, errClient)
|
||||
continue
|
||||
for i := 0; i < len(compatConfig.APIKeys); i++ {
|
||||
log.Debugf("Initializing OpenAI compatibility client for provider: %s", compatConfig.Name)
|
||||
compatClient, errClient := client.NewOpenAICompatibilityClient(cfg, &compatConfig, i)
|
||||
if errClient != nil {
|
||||
log.Errorf("failed to create OpenAI compatibility client for %s: %v", compatConfig.Name, errClient)
|
||||
continue
|
||||
}
|
||||
apiKeyClients[compatClient.GetClientID()] = compatClient
|
||||
openAICompatCount++
|
||||
}
|
||||
apiKeyClients[compatClient.GetClientID()] = compatClient
|
||||
openAICompatCount++
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user