-
Notifications
You must be signed in to change notification settings - Fork 840
Expand file tree
/
Copy pathProviderConfigEnvironment.swift
More file actions
43 lines (42 loc) · 1.41 KB
/
ProviderConfigEnvironment.swift
File metadata and controls
43 lines (42 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Foundation
public enum ProviderConfigEnvironment {
public static func applyAPIKeyOverride(
base: [String: String],
provider: UsageProvider,
config: ProviderConfig?) -> [String: String]
{
guard let apiKey = config?.sanitizedAPIKey, !apiKey.isEmpty else { return base }
var env = base
switch provider {
case .zai:
env[ZaiSettingsReader.apiTokenKey] = apiKey
case .copilot:
env["COPILOT_API_TOKEN"] = apiKey
case .minimax:
env[MiniMaxAPISettingsReader.apiTokenKey] = apiKey
case .alibaba:
env[AlibabaCodingPlanSettingsReader.apiTokenKey] = apiKey
case .kilo:
env[KiloSettingsReader.apiTokenKey] = apiKey
case .kimik2:
if let key = KimiK2SettingsReader.apiKeyEnvironmentKeys.first {
env[key] = apiKey
}
case .moonshot:
if let key = MoonshotSettingsReader.apiKeyEnvironmentKeys.first {
env[key] = apiKey
}
case .synthetic:
env[SyntheticSettingsReader.apiKeyKey] = apiKey
case .warp:
if let key = WarpSettingsReader.apiKeyEnvironmentKeys.first {
env[key] = apiKey
}
case .openrouter:
env[OpenRouterSettingsReader.envKey] = apiKey
default:
break
}
return env
}
}