jackMort / ChatGPT.nvim

ChatGPT Neovim Plugin: Effortless Natural Language Generation with OpenAI's ChatGPT API
Apache License 2.0
3.56k stars 307 forks source link

api_key_cmd is ignored if OPENAI_API_KEY is set #452

Open lukeemhigh opened 3 days ago

lukeemhigh commented 3 days ago

I use op as my api_key_cmd, but this only works if the OPENAI_API_KEY env var is not set.

I have exported my OPENAI_API_KEY to "op://Personal/OPENAI_API_KEY/credential" to be able to use the op run command to expand that variable and pass it to selected subprocesses, but this breaks the plugin because it seems that it defaults to get its api_key from env vars even if an api_key_cmd is set.

To me, the opposite behavior should be preferred.

thiswillbeyourgithub commented 3 days ago

Ohhhhh Thanks a lot because your issue made me understand why I had issues with launching the app through SSH or not. It was because I was setting the environment viable in just one of the two cases. Thanks a lot.