resolveAPIKey mirrors config.ProxyConfig.ResolveAPIKey. Duplicated (a few lines) rather than importing core/config from a backend binary — keeps backends independent of core's package layout. Mutual-exclusion is enforced upstream in core/config.Validate.
(envName, filePath string)
| 120 | // binary — keeps backends independent of core's package layout. |
| 121 | // Mutual-exclusion is enforced upstream in core/config.Validate. |
| 122 | func resolveAPIKey(envName, filePath string) (string, error) { |
| 123 | if envName != "" { |
| 124 | v := os.Getenv(envName) |
| 125 | if v == "" { |
| 126 | return "", fmt.Errorf("cloud-proxy: api_key_env %q is unset", envName) |
| 127 | } |
| 128 | return v, nil |
| 129 | } |
| 130 | if filePath != "" { |
| 131 | b, err := os.ReadFile(filePath) |
| 132 | if err != nil { |
| 133 | return "", fmt.Errorf("cloud-proxy: read api_key_file %q: %w", filePath, err) |
| 134 | } |
| 135 | return strings.TrimSpace(string(b)), nil |
| 136 | } |
| 137 | return "", nil |
| 138 | } |
| 139 | |
| 140 | // PredictRich is the non-streaming translate path. Returns a fully- |
| 141 | // populated *pb.Reply: content, tool-call deltas (ChatDeltas), and |