mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 00:53:33 +00:00
[fix] Droid: dynamic x-api-provider and custom User-Agent support
- Dynamic x-api-provider selection for OpenAI endpoint based on model - Models with '-max' suffix use 'openai' provider - Other models use 'azure_openai' provider - Fixes gpt-5.1-codex-max model compatibility issue - Update default User-Agent to factory-cli/0.32.1 - Add custom User-Agent field for Droid accounts - Backend: userAgent field in createAccount and updateAccount - Frontend: User-Agent input in account creation/edit UI - Supports all Droid auth modes: OAuth, Manual, API Key This resolves the issue where gpt-5.1-codex-max failed with 'Azure OpenAI only supports...' error due to incorrect provider header.
This commit is contained in:
@@ -556,7 +556,8 @@ class DroidAccountService {
|
||||
tokenType = 'Bearer',
|
||||
authenticationMethod = '',
|
||||
expiresIn = null,
|
||||
apiKeys = []
|
||||
apiKeys = [],
|
||||
userAgent = '' // 自定义 User-Agent
|
||||
} = options
|
||||
|
||||
const accountId = uuidv4()
|
||||
@@ -832,7 +833,8 @@ class DroidAccountService {
|
||||
: '',
|
||||
apiKeys: hasApiKeys ? JSON.stringify(apiKeyEntries) : '',
|
||||
apiKeyCount: hasApiKeys ? String(apiKeyEntries.length) : '0',
|
||||
apiKeyStrategy: hasApiKeys ? 'random_sticky' : ''
|
||||
apiKeyStrategy: hasApiKeys ? 'random_sticky' : '',
|
||||
userAgent: userAgent || '' // 自定义 User-Agent
|
||||
}
|
||||
|
||||
await redis.setDroidAccount(accountId, accountData)
|
||||
@@ -931,6 +933,11 @@ class DroidAccountService {
|
||||
sanitizedUpdates.endpointType = this._sanitizeEndpointType(sanitizedUpdates.endpointType)
|
||||
}
|
||||
|
||||
// 处理 userAgent 字段
|
||||
if (typeof sanitizedUpdates.userAgent === 'string') {
|
||||
sanitizedUpdates.userAgent = sanitizedUpdates.userAgent.trim()
|
||||
}
|
||||
|
||||
const parseProxyConfig = (value) => {
|
||||
if (!value) {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user