[BUG] Cipher Fails to Read Gemini API Key After First Startup
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
- Set the GEMINI_API_KEY environment variable.
- Start Cipher for the first time — Gemini is recognized and works.
- Stop and restart Cipher.
- 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
I'll have a look at that. Stay stuned!
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?
In my case, Cipher doesn't recognize GEMINI_API_KEY, but OPENAI_API_KEY works fine.
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.