jackMort / ChatGPT.nvim

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

API ERROR: We could not parse the JSON body of your request #184

Closed zpl-zak closed 1 year ago

zpl-zak commented 1 year ago

Hi, I am using NVIM v0.9.0 LuaJIT 2.1.0-beta3 Windows 11 Windows Terminal with MSYS2's bash shell

Whenever I execute any ChatGPT query I receive the following error:

ERROR: API Error

 // API ERROR: We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP
library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble
figuring out how to fix this, please contact us through our help center at help.openai.com.)

my API key is set in env and freshly created as well.

comiluv commented 1 year ago

I was having a similar problem. In my testing, Windows was adding random(?) whitespace at the end of the key string captured from reading environment variables and gnupg decryption. I'll make a PR that fixes this issue.