Nutlope / aicommits

A CLI that writes your git commit messages for you with AI
https://www.npmjs.com/package/aicommits
MIT License
8k stars 385 forks source link

Unable to Set OpenAI API Key #258

Open RayChang opened 12 months ago

RayChang commented 12 months ago

Bug description

I reinstalled aicommits globally using pnpm (8.11.0) and added the OpenAI_KEY in the settings. However, when I attempted to make a git commit using aicommits, I encountered an OpenAI API Error: 401 - Unauthorized message.

2023-12-01 11 30 27

Expected Behavior: Should be able to generate commit messages normally through aicommits.

aicommits version

1.11.0

Environment

System:
  OS: macOS 14.1.1
  CPU: Apple M1 Max
  Shell: /bin/zsh (5.9)
Binaries:
  Node: v18.18.2 ~/.nvm/versions/node/v18.18.2/bin/node
  npm: 9.8.1 ~/.nvm/versions/node/v18.18.2/bin/npm
  pnpm: 8.11.0 /opt/homebrew/bin/pnpm

Can you contribute a fix?

jchinkle commented 9 months ago

I am encountering this bug too. When I use aicommits config set to set the API key, it sets it in the .aicommits file in my home directory. However, it is not preferring that setting over an ENV variable. I have an ENV variable set (OPENAI_KEY) that is empty string, and it is attempting to use that instead of the value set in .aicommits.

KrustyHack commented 9 months ago

Ay,

I have the same issue and I still can't find from where the OPENAI_KEY variable is set. And .aicommits config does not seem to be taken into account with my new OpenAI API key.

xyNNN commented 6 months ago

What's the state about this issue? I'm having the same issue and can't identify where the OPENAI_KEY is defined.

xyNNN commented 6 months ago

Okay, for which reason it was configured with export OPENAI_KEY=XYZ in my .zshrc ... nevermind ;) A grep --recursive 'sk-XYZ' ./ helps