Skip to content

fix(cli): auto-propagate LLM_API_KEY to provider-specific env vars via config-driven detection#59

Open
wutongyuonce wants to merge 4 commits into
VectifyAI:mainfrom
wutongyuonce:main
Open

fix(cli): auto-propagate LLM_API_KEY to provider-specific env vars via config-driven detection#59
wutongyuonce wants to merge 4 commits into
VectifyAI:mainfrom
wutongyuonce:main

Conversation

@wutongyuonce
Copy link
Copy Markdown

No description provided.

@KylinMountain
Copy link
Copy Markdown
Collaborator

Thanks @wutongyuonce .

Since you're expanding the LLM_API_KEY propagation list, would you also consider adding a few other popular providers in the same vein?

  • Moonshot (Kimi)
  • Zhipu / GLM
  • Qwen (Alibaba)

All three are supported by LiteLLM and widely used; the env var names follow the same {PROVIDER}_API_KEY convention.

@wutongyuonce
Copy link
Copy Markdown
Author

Enhance LLM Provider Support and Streamline API Key Configuration Summary

This PR significantly expands OpenKB's support for major LLM providers and optimizes the logic for environment variable loading and distribution. By introducing a parallel "Unified Key" and "Provider-Specific Key" model, it greatly reduces configuration overhead for users while enhancing system robustness in complex multi-model scenarios.
Key Changes

1、Expanded Model Provider Support

  • Expanded the _KNOWN_PROVIDER_KEYS list in cli.py .
  • Added native support for several popular domestic and international providers:
    • Moonshot (Kimi) : MOONSHOT_API_KEY , KIMI_API_KEY
    • Zhipu (GLM) : ZHIPUAI_API_KEY , GLM_API_KEY
    • Alibaba (Qwen) : DASHSCOPE_API_KEY , QWEN_API_KEY
    • Also updated DeepSeek, Groq, Together AI, and others.

2、Optimized API Key Propagation Logic

  • Improved the _setup_llm_key function with "intelligent identification" capabilities.
  • Auto-Distribution : Setting a single LLM_API_KEY now automatically propagates it to all known provider variables, enabling "one-key configuration, full-range support."
  • Priority Respect : Ensures that specific PROVIDER_API_KEY s take precedence over the unified LLM_API_KEY , protecting fine-grained user configurations from being overwritten.

3、Refactored .env.example Template

  • Redesigned the structure of .env.example into clear sections:
    • Option 1 (Unified) : The recommended simple setup.
    • Option 2 (Specific) : Advanced management for multiple providers.
  • Added a Configuration Architecture Note at the top of the file to clarify the relationship between .env (Authorization) and config.yaml (Model Routing), lowering the barrier for new users.

Comment thread openkb/cli.py Outdated
click.echo(" OpenAI: gpt-5.4-mini, gpt-5.4")
click.echo(" Anthropic: anthropic/claude-sonnet-4-6, anthropic/claude-opus-4-6")
click.echo(" Gemini: gemini/gemini-3.1-pro-preview, gemini/gemini-3-flash-preview")
click.echo(" DeepSeek: deepseek/deepseek-v4-flash, deepseek/deepseek-v4-0417")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not deepseek-v4-pro?

Comment thread openkb/cli.py Outdated
_KNOWN_PROVIDER_KEYS = (
"OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GEMINI_API_KEY",
"DEEPSEEK_API_KEY", "COHERE_API_KEY", "MISTRAL_API_KEY",
"TOGETHER_API_KEY", "GROQ_API_KEY", "MOONSHOT_API_KEY",
Copy link
Copy Markdown
Collaborator

@KylinMountain KylinMountain May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove Together, GROQ and Cohere. I believe they are distributors, not model providers. Is that correct?

KIMI or MOONSHOT? ZHIPU or GLM, DASHSCOPE or QWEN ? Please help to confirm this confusion, thanks.

Comment thread .env.example Outdated
# OpenAI: LLM_API_KEY=sk-...
# Anthropic: LLM_API_KEY=sk-ant-...
# Gemini: LLM_API_KEY=AIza...
# ==============================================================================
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we need to modify this env example file. Adding DeepSeek should be sufficient.

Comment thread uv.lock Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove this file, we have it in repo.

@wutongyuonce
Copy link
Copy Markdown
Author

I have made the modifications as you said.

  • remove Together, GROQ and Cohere
  • remove "KIMI_API_KEY", "GLM_API_KEY" and "QWEN_API_KEY"
  • change "deepseek/deepseek-v4-0417" to "deepseek/deepseek-v4-pro"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants