feat(config): add OpenAI-compatible custom provider support#67
feat(config): add OpenAI-compatible custom provider support#67gcaguilar wants to merge 3 commits into
Conversation
Allow any OpenAI-compatible endpoint via CUSTOM_API_KEY, CUSTOM_BASE_URL, and CUSTOM_MODEL env vars. Useful for LiteLLM, LocalAI, LM Studio, vLLM, and other OpenAI API proxies. Updates hasProvider validation in both configure.js and entrypoint.sh so the container starts with only CUSTOM_API_KEY set. Adds 34 tests in scripts/configure.test.js covering provider config, base URL handling, model defaults, priority selection, and hasProvider.
|
I need this PR to be merged soon |
|
@andrasbacsai Could you take a look at the PR, please? |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis PR adds support for OpenAI-compatible custom providers, enabling users to configure self-hosted or alternative endpoints via three environment variables: Come with me if you want to live... behind your own self-hosted servers instead of paying VC-backed serverless tax. This PR is good. It is very good. Now where is my gluten-free taco? The test suite is 409 lines of beautiful, hardened logic—no framework bloat, no magic. The Terminator approves. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/configure.js`:
- Line 373: The primaryCandidates array is hardcoded to
"openai-compatible/gpt-4" and doesn't honor the CUSTOM_MODEL used when
constructing the provider's models (the block that creates a model with
CUSTOM_MODEL around where models are defined and referenced by
primaryCandidates); update the primaryCandidates entry to use the same
CUSTOM_MODEL variable (e.g., process.env.CUSTOM_MODEL or the local constant used
to build the provider model) instead of the literal "openai-compatible/gpt-4" so
the auto-selection matches the provider's actual model ID.
In `@scripts/configure.test.js`:
- Around line 304-361: The test suite misses a case verifying CUSTOM_MODEL is
used when building primaryCandidates: update the tests in configure.test.js to
add a test (similar to the proposed snippet) that sets
process.env.CUSTOM_API_KEY and process.env.CUSTOM_MODEL and asserts the selected
model equals `openai-compatible/${process.env.CUSTOM_MODEL}`; ensure the
primaryCandidates entry for the custom provider uses `process.env.CUSTOM_MODEL
|| 'gpt-4'` so it mirrors the behavior expected by configure.js (see
configure.js line referenced around the primaryCandidates construction).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0a69d2e6-a1a1-4ff5-a166-896ae1690ff9
📒 Files selected for processing (5)
.env.exampleREADME.mdscripts/configure.jsscripts/configure.test.jsscripts/entrypoint.sh
|
@andrasbacsai Comments applied |
Summary
CUSTOM_API_KEY,CUSTOM_BASE_URL, andCUSTOM_MODELenv vars for any OpenAI-compatible endpoint (LiteLLM, LocalAI, LM Studio, vLLM, etc.)hasProvidervalidation in bothconfigure.jsandentrypoint.shso the container starts with onlyCUSTOM_API_KEYsetscripts/configure.test.jscovering provider config, base URL handling, model defaults, priority selection, and hasProviderDetails
The existing provider system supports built-in providers (Anthropic, OpenAI, Gemini, etc.) and custom/proxy providers that require a full
models.providersconfig block. This PR adds a dedicated env-var path for OpenAI-compatible providers, following the same pattern as Venice AI, Moonshot, and Ollama.Files changed (5 files, +442/-5)
scripts/configure.jsscripts/entrypoint.sh.env.exampleREADME.mdscripts/configure.test.jsProvider config
{ "models": { "providers": { "openai-compatible": { "api": "openai-completions", "apiKey": "<CUSTOM_API_KEY>", "baseUrl": "<CUSTOM_BASE_URL or https://api.openai.com/v1>", "models": [{ "id": "<CUSTOM_MODEL or gpt-4>", "name": "...", "contextWindow": 128000 }] } } } }Env vars
CUSTOM_API_KEYCUSTOM_BASE_URLhttps://api.openai.com/v1CUSTOM_MODELgpt-4