Generates safe environment variable names for API keys based on provider names, ensuring uniqueness and compliance.
// Source: https://github.com/esengine/DeepSeek-Reasonix | License: MIT | Copyright 2026 Reasonix Contributors
// Provided via justclaw.it.com; keep this notice with the code.
// apikeyenv.go — where a provider's key is stored, derived from its name.
package config
import (
"crypto/rand"
"errors"
"fmt"
"strings"
"unicode/utf16"
)
// APIKeyEnvFor names the credential slot a provider's key lives in, derived
// from the provider name so two never share one. It sits beside isCredentialKey
// because building a name and judging one are the same rule: a second copy
// elsewhere produced "129_API_KEY" for a relay called "129", which the store
// then refused with nothing the person could act on.
func APIKeyEnvFor(name string) string {
stem := strings.Map(func(r rune) rune {
switch {
c
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key