Closed Dakai closed 1 year ago
☝🏻 this!
It says in the documentation that you can set the OPENAI_API_KEY
environment variable to make this work, but that is not the case, and you in fact need to set the openai_api_key
option in the config, which as @Dakai had pointed out, will be exposed if one's Neovim config is pushed to GitHub (which most people's is)...
Hey @LSleutsky , actually, I just found out that it works with OPENAI_API_KEY
environment variable when I just delete the openai_api_key
option in the config.
Hmm, really? That's bizarre, it doesn't work for me. Sometimes it gives me an error message that I've exceeded my API billing usage, even tho I have tons of credits on my OpenAI account, and have tried creating new keys and setting it to the env variable you mention, and still nada!
Will try to dig around and see why. Thanks for the reply...!
Another option if you manage your dotfiles with git is to keep the API keys in a Lua file that's in your .gitignore. Here's how I do it:
https://github.com/b0o/nvim-conf/blob/main/lua/user/private.example.lua
Just to clarify, wtf.nvim
will respect the OPENAI_API_KEY
environment variable. The openai_api_key
is an alternative way to set your key, and will override the environment variable if present - which is useful for testing or people who don't want to set it via the environment variable. Hope that helps!
Another alternative is to have the key in pass
and declare it inside the env var like this:
OPENAI_API_KEY=$(pass show openai-api-key)
on fish shell:
set -g OPENAI_API_KEY (pass show openai-api-key)
People including me backs up their dot file in Github or other cloud platforms may accidentally expose their API key to the public, which I just did.