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

[Feature Request] Specify API keys using environment variables #57

Open
Alby11 opened this issue Nov 28, 2024 · 3 comments
Open

[Feature Request] Specify API keys using environment variables #57

Alby11 opened this issue Nov 28, 2024 · 3 comments

Comments

@Alby11
Copy link

Alby11 commented Nov 28, 2024

Hi @tom-doerr!

It would be great, in order to store them in a safer way.

Thanks for your help.

@tom-doerr
Copy link
Owner

Why would it be safer to have them as environment variables? Wouldn't that mean that every program can just pull them from the environment? Not saying you aren't correct, just genuinely curious.
I believe the openai package already reads the API-key from the environment if it is set there, I think the question is just if we are overwriting it or an error is thrown if it's not set in the config: https://github.com/tom-doerr/zsh_codex/blob/7f1def91142dc0b66bf8010315000e23c1201355/services/services.py#L47C34-L47C41

Do you want to investigate? I would merge a PR for this

@Alby11
Copy link
Author

Alby11 commented Nov 29, 2024

Dear Tom, thank you for your response.

Based on my experience, utilizing environment variables instead of configuration files can enhance security by mitigating the risk of accidental permission errors. In my workflow, I retrieve the OPENAI_API_KEY from AWS Secrets Manager during shell startup. This approach streamlines the process of transferring my dotfiles to different systems and facilitates sharing.

I am currently working on a fork of your repository to implement this feature. The functionality will prioritize checking for the environment variable and, if absent, defaulting to the configuration file.

Furthermore, I'd like to implement the possibility to eliminate the config file entirely, particularly by designating a service (e.g., OpenAI) as the default.

I would appreciate your feedback on these proposed changes.

@tom-doerr
Copy link
Owner

Sounds good! How about making the the config file optional? Would hate to break people's setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants