Skip to content

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

@GenKoKo

Description

@GenKoKo

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions