mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
Add support for Codex API key authentication
- Introduced functionality to handle Codex API keys, including initialization and management via new endpoints in the management API. - Updated Codex client to support both OAuth and API key authentication. - Documented Codex API key configuration in both English and Chinese README files. - Enhanced logging to distinguish between API key and OAuth usage scenarios.
This commit is contained in:
@@ -185,6 +185,9 @@ func (w *Watcher) reloadConfig() {
|
||||
if len(oldConfig.ClaudeKey) != len(newConfig.ClaudeKey) {
|
||||
log.Debugf(" claude-api-key count: %d -> %d", len(oldConfig.ClaudeKey), len(newConfig.ClaudeKey))
|
||||
}
|
||||
if len(oldConfig.CodexKey) != len(newConfig.CodexKey) {
|
||||
log.Debugf(" codex-api-key count: %d -> %d", len(oldConfig.CodexKey), len(newConfig.CodexKey))
|
||||
}
|
||||
if oldConfig.AllowLocalhostUnauthenticated != newConfig.AllowLocalhostUnauthenticated {
|
||||
log.Debugf(" allow-localhost-unauthenticated: %t -> %t", oldConfig.AllowLocalhostUnauthenticated, newConfig.AllowLocalhostUnauthenticated)
|
||||
}
|
||||
@@ -364,6 +367,18 @@ func (w *Watcher) reloadClients() {
|
||||
log.Debugf("Successfully initialized %d Claude API Key clients", claudeAPIKeyCount)
|
||||
}
|
||||
|
||||
codexAPIKeyCount := 0
|
||||
if len(cfg.CodexKey) > 0 {
|
||||
log.Debugf("processing %d Codex API Keys", len(cfg.CodexKey))
|
||||
for i := 0; i < len(cfg.CodexKey); i++ {
|
||||
log.Debugf("Initializing with Codex API Key %d...", i+1)
|
||||
cliClient := client.NewCodexClientWithKey(cfg, i)
|
||||
newClients = append(newClients, cliClient)
|
||||
codexAPIKeyCount++
|
||||
}
|
||||
log.Debugf("Successfully initialized %d Codex API Key clients", codexAPIKeyCount)
|
||||
}
|
||||
|
||||
// Add clients for OpenAI compatibility providers if configured
|
||||
openAICompatCount := 0
|
||||
if len(cfg.OpenAICompatibility) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user