Skip to content

Refactor/generic ai provider#58

Open
lastk wants to merge 4 commits intostandardagents:mainfrom
lastk:refactor/generic-ai-provider
Open

Refactor/generic ai provider#58
lastk wants to merge 4 commits intostandardagents:mainfrom
lastk:refactor/generic-ai-provider

Conversation

@lastk
Copy link

@lastk lastk commented Mar 16, 2026

Replaces all hardcoded OpenRouter API references with a centralized aiProvider module that supports any provider implementing the OpenAI API specification. Users can now point dmux at OpenAI, Ollama, LM Studio, vLLM, or any other compatible endpoint by setting standard environment variables.

Previously, OPENROUTER_API_KEY, the OpenRouter base URL, and a hardcoded model list were duplicated across five files (aiMerge.ts, PaneAnalyzer.ts, slug.ts, MergePane.tsx, onboarding.ts). This made it impossible to use a different provider without patching source code.

The new src/utils/aiProvider.ts exposes three config accessors consumed by all callers:

  • OPENAI_API_KEY — API key (falls back to OPENROUTER_API_KEY for backwards compatibility)
  • OPENAI_BASE_URL — provider base URL (default: https://openrouter.ai/api/v1)
  • OPENAI_MODEL — comma-separated model list to try in order (overrides the default fallback chain)

Existing users with OPENROUTER_API_KEY set require no changes. The onboarding flow and shell config persistence (aiApiKeySetup.ts) were updated to write OPENAI_API_KEY going forward, and migrate any existing # >>> dmux openrouter >>> shell config blocks automatically.

lastk added 4 commits March 15, 2026 23:15
Introduces src/utils/aiProvider.ts with getApiKey(), getBaseUrl(), and
getModels() accessors that read from OPENAI_API_KEY, OPENAI_BASE_URL,
and OPENAI_MODEL env vars, falling back to OPENROUTER_API_KEY and
OpenRouter defaults for backwards compatibility.
Update aiMerge, PaneAnalyzer, slug, MergePane, and StatusDetector to
use the centralized getApiKey/getBaseUrl/getModels accessors instead of
hardcoding the OpenRouter URL, API key env var, and model list.
Generalize onboarding and shell config persistence to use OPENAI_API_KEY
instead of OPENROUTER_API_KEY. Migrate legacy shell config blocks and
onboarding state. Update all test files accordingly.
@marc-shen
Copy link

It's a nice enhance. But in some cases, to connect all these ai providers should use a proxy, I'm not sure if these changes can connect to the proxy now.
#43

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.

2 participants