feat: support ANTHROPIC_API_KEY field and add AiHubMix provider
Add compatibility for providers that use ANTHROPIC_API_KEY instead of ANTHROPIC_AUTH_TOKEN, enabling support for AiHubMix and similar services. Changes: - Backend: Add fallback to ANTHROPIC_API_KEY in credential extraction - migration.rs: Support API_KEY during config migration - services/provider.rs: Extract credentials from either field - Frontend: Smart API key field detection and management - getApiKeyFromConfig: Read from either field (AUTH_TOKEN priority) - setApiKeyInConfig: Write to existing field, preserve user choice - hasApiKeyField: Detect presence of either field - Add AiHubMix provider preset with dual endpoint candidates - Define apiKeyField metadata for provider presets (documentation) Technical Details: - Uses or_else() for zero-cost field fallback in Rust - Runtime field detection ensures correct field name preservation - Maintains backward compatibility with existing configurations - Priority: ANTHROPIC_AUTH_TOKEN > ANTHROPIC_API_KEY
This commit is contained in:
@@ -1032,6 +1032,7 @@ impl ProviderService {
|
||||
|
||||
let api_key = env
|
||||
.get("ANTHROPIC_AUTH_TOKEN")
|
||||
.or_else(|| env.get("ANTHROPIC_API_KEY"))
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or_else(|| {
|
||||
AppError::localized(
|
||||
|
||||
Reference in New Issue
Block a user