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

valid_token_dict error with OPENAI environment variables #417

Closed rustikus closed 3 months ago

rustikus commented 3 months ago

Hi,

in my .lua config i set the following values: api_host_cmd and api_key_cmd

That works fine in general but if I also set the environment variable OPENAI_API_KEY the following error occurs:

Authentication Error, local variable 'valid_token_dict' referenced before assignment

Not sure if I am missing something.

Thanks!

rustikus commented 3 months ago

OK, it seems this was a config problem

For reference: If you are using an api_key_cmd for a custom api_host_cmd in your config.

If you want to use another OPENAI_API_KEY for the default OpenAI API you also need to set up the environment variable to the default endpoint OPENAI_API_HOST=api.openai.com