Skip to content

Allow LM Studio provider to run in no-key mode for AI smoke and local narration flows - #34

Draft
SweetingTech with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-lm-studio-api-key-requirement
Draft

Allow LM Studio provider to run in no-key mode for AI smoke and local narration flows#34
SweetingTech with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-lm-studio-api-key-requirement

Conversation

Copilot AI commented May 18, 2026

Copy link
Copy Markdown
Contributor

/api/ai/test_provider failed for provider=lmstudio when OPENAI_API_KEY was unset/empty, despite LM Studio being reachable and expected to work in local no-key mode. This blocked setup QA and contradicted local OpenAI-compatible behavior expected for demo/release verification.

  • LM Studio-only credential fallback

    • Updated _openai_client_for() to apply a dummy fallback key only for provider == "lmstudio" when OPENAI_API_KEY is empty/missing.
    • Kept existing credential behavior unchanged for all other providers.
  • Regression coverage for provider-specific auth behavior

    • Added contract test validating POST /api/ai/test_provider succeeds for LM Studio with empty env key.
    • Added parameterized regression test confirming non-LM Studio providers (openai, ollama, openrouter) retain existing env-key pass-through behavior.
def _openai_client_for(provider: str, base_url: str | None):
    final_base_url = resolve_provider_base_url(provider, base_url)
    if provider and provider.lower() == "lmstudio":
        api_key = os.environ.get("OPENAI_API_KEY") or "lmstudio-local"
    else:
        api_key = os.environ.get("OPENAI_API_KEY", "dev-local")
    return OpenAI(api_key=api_key, base_url=final_base_url)

Copilot AI and others added 2 commits May 18, 2026 09:54
Copilot AI changed the title [WIP] Fix LM Studio local provider to allow no-key mode Allow LM Studio provider to run in no-key mode for AI smoke and local narration flows May 18, 2026
Copilot AI requested a review from SweetingTech May 18, 2026 09:57
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.

[QA:ai] LM Studio local provider still requires API key

2 participants