ProviderAPIKeyEnvVars returns the deduplicated, sorted set of environment variables that hold a dedicated model-provider API key. Callers that need to forward provider credentials (e.g. into a container) should use this instead of hard-coding a list of API key names, so it stays in sync as providers
()
| 164 | // and broad general-purpose tokens (see nonForwardableTokenEnvVars). Providers |
| 165 | // needing those must be given credentials explicitly. |
| 166 | func ProviderAPIKeyEnvVars() []string { |
| 167 | seen := map[string]bool{} |
| 168 | add := func(name string) { |
| 169 | if name != "" && !nonForwardableTokenEnvVars[name] { |
| 170 | seen[name] = true |
| 171 | } |
| 172 | } |
| 173 | for _, p := range cloudProviders { |
| 174 | add(p.apiKeyEnvVar) |
| 175 | } |
| 176 | for _, alias := range provider.EachAlias() { |
| 177 | add(alias.TokenEnvVar) |
| 178 | } |
| 179 | return slices.Sorted(maps.Keys(seen)) |
| 180 | } |
| 181 | |
| 182 | func AvailableProviders(ctx context.Context, modelsGateway string, env environment.Provider) []string { |
| 183 | if modelsGateway != "" { |