Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llm keys get name command #623

Closed
simonw opened this issue Nov 11, 2024 · 2 comments
Closed

llm keys get name command #623

simonw opened this issue Nov 11, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Nov 11, 2024

I didn't implement this at first because I didn't like the idea of key secrets being easy to read back out again. Then I found myself doing things like this:

OPENAI_API_KEY="$(jq -r '.openai' "$(dirname "$(llm logs path)")/keys.json")" \
  uv run jupyter notebook

The keys.json file is readable by the current user anyway, so may as well simplify this pattern to the much nicer:

OPENAI_API_KEY="$(llm keys get openai)" uv run jupyter notebook
@simonw simonw added the enhancement New feature or request label Nov 11, 2024
simonw added a commit that referenced this issue Nov 11, 2024
@simonw
Copy link
Owner Author

simonw commented Nov 11, 2024

This now works:

OPENAI_API_KEY="$(llm keys get openai)" printenv OPENAI_API_KEY

Surprisingly (to me) this didn't - it output an empty string:

OPENAI_API_KEY="$(llm keys get openai)" echo $OPENAI_API_KEY

Turns out echo is a builtin shell command (macOS zsh at least) - so OPENAI_API_KEY is expanded before the environment has been updated. printenv is a program so it gets the updated environment.

@simonw
Copy link
Owner Author

simonw commented Nov 11, 2024

Updated docs - since this is such a small feature I only bothered documenting it in --help and through that on the CLI reference page: https://github.com/simonw/llm/blob/dff53a9caebd01acdb8c79f6f52e0b5f8b038475/docs/help.md#llm-keys-get---help

simonw added a commit that referenced this issue Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant