byterover-cli icon indicating copy to clipboard operation
byterover-cli copied to clipboard

[BUG] Cipher Fails to Read Gemini API Key After First Startup

Open GenKoKo opened this issue 1 year ago • 4 comments

Bug Description

On the first startup, Cipher correctly recognizes the GEMINI_API_KEY and Gemini works as expected. However, on subsequent startups, Cipher fails to detect the Gemini API key and displays an error requesting other API keys.

Steps to Reproduce

  1. Set the GEMINI_API_KEY environment variable.
  2. Start Cipher for the first time — Gemini is recognized and works.
  3. Stop and restart Cipher.
  4. Observe that Cipher now displays an error: "No API key or Ollama configuration found..." and does not recognize the GEMINI_API_KEY.

Expected Behavior

Cipher should consistently read the GEMINI_API_KEY and allow Gemini to be used as a provider on every startup, not just the first time.

Actual Behavior

Cipher only recognizes the GEMINI_API_KEY on the first run. On subsequent runs, it fails to detect the key and blocks startup with an error.

Screenshots

N/A (error occurs in the command line).

Environment Information

  • OS: macOS Sequoia 15.6.1
  • Version: cipher 0.3.0
  • Node.js version: 23.11.0

Logs and Error Messages

10:14:00 ERROR: No API key or Ollama configuration found, please set at least one of OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY, OLLAMA_BASE_URL, or AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION) in your environment variables
Available providers: OpenAI, Anthropic, OpenRouter, Ollama, Qwen, Gemini, Azure, AWS, LM Studio

Additional Context

The GEMINI_API_KEY is set and unchanged between runs. The issue only occurs after the first startup.

Possible Solution

  • Investigate caching or state persistence that may affect API key detection after the first run.
  • Ensure GEMINI_API_KEY is checked on every startup.
  • Update documentation or code to clarify/reinforce correct provider initialization.

Checklist

  • [x] Searched for similar issues
  • [x] Provided all required information
  • [x] Tested on the latest version

GenKoKo avatar Sep 14 '25 01:09 GenKoKo

I'll have a look at that. Stay stuned!

RyanNg1403 avatar Sep 16 '25 16:09 RyanNg1403

Sorry for the inconvenience you experienced. I’ve tried running Cipher in different ways but wasn’t able to reproduce the issue on my side. Could you share more details about how you installed and ran Cipher, as well as the exact steps that led to the problem?

willingWill17 avatar Sep 17 '25 14:09 willingWill17

In my case, Cipher doesn't recognize GEMINI_API_KEY, but OPENAI_API_KEY works fine.

felipfr avatar Sep 27 '25 13:09 felipfr

Thank you for reporting the error in the code. I’ve opened PR #264 to resolve this issue. Please check out the latest code and let me know your feedback.

willingWill17 avatar Sep 28 '25 14:09 willingWill17