Repository navigation
feat(config, llm): Read an API key from a list of env vars - #1244
Merged
Merged
Conversation
`api_key_env` accepts a list of environment variables. The list is one
key: JP reads the variables in order and uses the first one holding a
non-empty value. A blank value falls through to the next variable, as
it already falls through between `auth` chain entries.
```toml
[providers.llm.vllm]
api_key_env = ["WORK_KEY", "USER_KEY"]
```
A named key in the map form may be a list too. `api_key:work` then
tries each of its variables before the `auth` chain moves on to the
next entry, and still reports the credential as `api_key:work`:
```toml
api_key_env = { work = ["WORK_KEY", "WORK_KEY_OLD"], personal = "KEY" }
```
When nothing in a list is set, the error names every variable tried
(`Missing environment variable: WORK_KEY or USER_KEY`). A named key
with an empty list is reported by its name rather than as a missing
variable with no name. `--cfg` accepts both shapes in JSON form, e.g.
`--cfg 'providers.llm.vllm.api_key_env:=["A","B"]'`, where it rejected
arrays before. `jp provider ls` lists one `api_key` row per variable,
in the order they are tried, so it shows which one is set.
Applies to every provider with an `api_key_env`: Anthropic, Cerebras,
DeepSeek, Google, OpenAI, OpenRouter, and vLLM. Existing string and map
configs are unchanged.
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Nothing converts a `String` into `KeyVariables`; every caller builds one from a `&str` or a variant constructor. The impl was also a trivial wrap, which rustqual counts as boilerplate (BP-001), and it pushed `boilerplate_warnings` one above the committed baseline, failing `just qual-ci`. Signed-off-by: Jean Mertz <git@jeanmertz.com>
JeanMertz
force-pushed
the
multi-key-support
branch
from
October 6, 2026 20:52
8ac755e to
4b0a4c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
api_key_envaccepts a list of environment variables. The list is one key: JP reads the variables in order and uses the first one holding a non-empty value. A blank value falls through to the next variable, as it already falls through betweenauthchain entries.A named key in the map form may be a list too.
api_key:workthen tries each of its variables before theauthchain moves on to the next entry, and still reports the credential asapi_key:work:When nothing in a list is set, the error names every variable tried (
Missing environment variable: WORK_KEY or USER_KEY). A named key with an empty list is reported by its name rather than as a missing variable with no name.--cfgaccepts both shapes in JSON form, e.g.--cfg 'providers.llm.vllm.api_key_env:=["A","B"]', where it rejected arrays before.jp provider lslists oneapi_keyrow per variable, in the order they are tried, so it shows which one is set.Applies to every provider with an
api_key_env: Anthropic, Cerebras, DeepSeek, Google, OpenAI, OpenRouter, and vLLM. Existing string and map configs are unchanged.