router-for-me/CLIProxyAPI · error
openai-compatibility[%d].api-key-entries[%d].weight: %w
Error message
openai-compatibility[%d].api-key-entries[%d].weight: %w
What it means
Returned while validating weights inside an openai-compatibility provider block. Each provider's api-key-entries[keyIndex].weight is checked with ValidateCredentialWeight; the error names both the provider index and the key-entry index so you can locate the exact nested entry in config.yaml.
Source
Thrown at internal/config/weight.go:148
if errValidate := ValidateCredentialWeight(cfg.VertexCompatAPIKey[index].Weight); errValidate != nil {
return fmt.Errorf("vertex-api-key[%d].weight: %w", index, errValidate)
}
}
for index := range cfg.CodexKey {
if errValidate := ValidateCredentialWeight(cfg.CodexKey[index].Weight); errValidate != nil {
return fmt.Errorf("codex-api-key[%d].weight: %w", index, errValidate)
}
}
for index := range cfg.XAIKey {
if errValidate := ValidateCredentialWeight(cfg.XAIKey[index].Weight); errValidate != nil {
return fmt.Errorf("xai-api-key[%d].weight: %w", index, errValidate)
}
}
for providerIndex := range cfg.OpenAICompatibility {
for keyIndex := range cfg.OpenAICompatibility[providerIndex].APIKeyEntries {
weight := cfg.OpenAICompatibility[providerIndex].APIKeyEntries[keyIndex].Weight
if errValidate := ValidateCredentialWeight(weight); errValidate != nil {
return fmt.Errorf("openai-compatibility[%d].api-key-entries[%d].weight: %w", providerIndex, keyIndex, errValidate)
}
}
}
return nil
}
View on GitHub (pinned to 78f0c4079e)
Solutions
- Locate openai-compatibility[p] (count from 0) and its api-key-entries[k]; set weight to 1..1000000
- Remember the index in the message is the array position, not a name — count entries in file order
- Re-check after reload; validation covers all providers so fix every flagged entry
Example fix
# before
openai-compatibility:
- name: my-provider
api-key-entries:
- api-key: sk-...
weight: 2000000
# after
openai-compatibility:
- name: my-provider
api-key-entries:
- api-key: sk-...
weight: 2 Defensive patterns
Strategy: validation
Validate before calling
for p, prov := range cfg.OpenAICompatibility {
for k, entry := range prov.APIKeyEntries {
if _, err := credentialweight.Normalize(entry.Weight); err != nil {
return fmt.Errorf("openai-compatibility[%d].api-key-entries[%d].weight: %w", p, k, err)
}
}
} Prevention
- When editing nested openai-compatibility blocks, remember weight lives per api-key-entry, not per provider
- Count array positions from 0 to map the error's indices back to the file
- Prefer config templating over hand-edited YAML for repeated key entries
When it happens
Trigger: config.yaml where openai-compatibility[p].api-key-entries[k].weight fails credentialweight.Normalize (value > 1000000 or otherwise invalid). Fires at config load or hot-reload.
Common situations: Nested providers make the path easy to get wrong: editing provider-level options instead of the per-key weight, or pasting a key entry whose weight was tuned for a different system with a different scale.
Related errors
- codex-api-key[%d].weight: %w
- xai-api-key[%d].weight: %w
- codex.live-media-relay.max-sessions must not be negative
- codex.live-media-relay UDP port minimum and maximum must bot
- codex.live-media-relay.udp-port-min must not exceed udp-port
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/e676d1f4c1d2118e.
Report an issue: GitHub.