MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / add_provider

Function add_provider

uncommon_route/providers.py:139–160  ·  view source on GitHub ↗

Add or update a provider. Returns updated config (also saves to disk).

(
    name: str,
    api_key: str,
    base_url: str | None = None,
    models: list[str] | None = None,
    plan: str = "",
    config: ProvidersConfig | None = None,
)

Source from the content-addressed store, hash-verified

137
138
139def add_provider(
140 name: str,
141 api_key: str,
142 base_url: str | None = None,
143 models: list[str] | None = None,
144 plan: str = "",
145 config: ProvidersConfig | None = None,
146) -> ProvidersConfig:
147 """Add or update a provider. Returns updated config (also saves to disk)."""
148 cfg = config or load_providers()
149 resolved_url = base_url or KNOWN_BASE_URLS.get(name, "")
150 resolved_models = models or PROVIDER_MODELS.get(name, [])
151
152 cfg.providers[name] = ProviderEntry(
153 name=name,
154 api_key=api_key,
155 base_url=resolved_url,
156 models=resolved_models,
157 plan=plan,
158 )
159 save_providers(cfg)
160 return cfg
161
162
163def remove_provider(name: str, config: ProvidersConfig | None = None) -> bool:

Callers 12

test_add_providerMethod · 0.90
test_remove_providerMethod · 0.90
test_persistenceMethod · 0.90
test_keyed_modelsMethod · 0.90
test_get_for_modelMethod · 0.90
_cmd_initFunction · 0.90
handle_providersFunction · 0.90
apply_planFunction · 0.90
cmd_providerFunction · 0.85

Calls 4

load_providersFunction · 0.85
ProviderEntryClass · 0.85
save_providersFunction · 0.85
getMethod · 0.45

Tested by 8

test_add_providerMethod · 0.72
test_remove_providerMethod · 0.72
test_persistenceMethod · 0.72
test_keyed_modelsMethod · 0.72
test_get_for_modelMethod · 0.72