feat: configurable API endpoints via {PROVIDER}_BASE_URL convention#6
Merged
Star-Lotus merged 1 commit intomainfrom Mar 10, 2026
Merged
feat: configurable API endpoints via {PROVIDER}_BASE_URL convention#6Star-Lotus merged 1 commit intomainfrom
Star-Lotus merged 1 commit intomainfrom
Conversation
Add a unified endpoint registry (src/utils/endpoints.py) with
get_provider_base_url() utility. All hardcoded API URLs in model
adapters (DashScope, Kling, Vidu) now read from environment variables,
enabling international deployment with a single env var change.
Backend:
- New src/utils/endpoints.py with PROVIDER_DEFAULTS + helper
- Replace hardcoded URLs in wanx.py, image.py, qwen_vl.py,
llm_adapter.py, kling.py, vidu.py
- EnvConfig gains endpoint_overrides dict with allowlist validation
- GET/POST /config/env handle endpoint collection and persistence
- Add remove_user_config_keys() for proper override clearing
Frontend:
- ENDPOINT_PROVIDERS registry in EnvConfigDialog.tsx
- Collapsible "Advanced: API Endpoints" section with .map() rendering
- Safe endpoint_overrides loading with ?? {} fallback
- Update api.ts saveEnvConfig type for nested Record
- 28 new vitest tests covering all extracted logic
Config:
- .env.example documents {PROVIDER}_BASE_URL convention
- vitest added as devDependency
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/utils/endpoints.py) withget_provider_base_url()utility andPROVIDER_DEFAULTSdict{PROVIDER}_BASE_URLenv var overrides default, empty string falls back to defaultMotivated by PR #4's idea of endpoint configurability, but implemented with a convention-over-configuration approach. New provider onboarding = 3 lines of code (one in
PROVIDER_DEFAULTS, one in model class, one in frontend registry).Changes
Backend:
src/utils/endpoints.py— provider registry +get_provider_base_url()with trailing-slash stripping and empty-string fallbackwanx.py,image.py,qwen_vl.py,llm_adapter.py,kling.py,vidu.py— replaced hardcoded URLsapi.py—EnvConfig.endpoint_overridesdict with allowlist validation,remove_user_config_keys()for proper override clearing, deduplicated GET routeFrontend:
EnvConfigDialog.tsx—ENDPOINT_PROVIDERSregistry, collapsible endpoint section, safe?? {}fallbackapi.ts— updatedsaveEnvConfigtype signatureTests & Config:
.env.exampledocuments{PROVIDER}_BASE_URLconvention with international endpoint examplesTest plan
DASHSCOPE_BASE_URL=https://test.example.com→ requests go to new endpointendpoint_overridesrejected (allowlist validation).env/ JSON)