Merge pull request #1571 from aiapienthusiast/feature/cheaper-inference-provider

feat: add Cheaper Inference as an LLM provider
This commit is contained in:
Bingxi Zhao
2026-09-27 02:36:55 +08:00
committed by GitHub
5 changed files with 84 additions and 0 deletions

View File

@@ -155,6 +155,7 @@ PROVIDER_ALIASES = {
"novita_ai": "novita",
"orca_router": "orcarouter",
"orca-router": "orcarouter",
"cheaper_inference": "cheaperinference",
}
@@ -298,6 +299,16 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
detect_by_base_keyword="unifically",
default_api_base="https://api.unifically.com/v1",
),
ProviderSpec(
name="cheaperinference",
keywords=("cheaperinference",),
env_key="CHEAPER_INFERENCE_API_KEY",
display_name="Cheaper Inference",
backend="openai_compat",
is_gateway=True,
detect_by_base_keyword="cheaperinference",
default_api_base="https://api.cheaperinference.com/v1",
),
ProviderSpec(
name="volcengine",
keywords=("volcengine", "volces", "ark"),

View File

@@ -670,6 +670,13 @@ def test_llm_provider_choices_include_unifically() -> None:
assert llm["unifically"]["base_url"] == "https://api.unifically.com/v1"
def test_llm_provider_choices_include_cheaperinference() -> None:
llm = {item["value"]: item for item in settings_router._provider_choices()["llm"]}
assert llm["cheaperinference"]["label"] == "Cheaper Inference"
assert llm["cheaperinference"]["base_url"] == "https://api.cheaperinference.com/v1"
def test_llm_provider_choices_include_novita() -> None:
llm = {item["value"]: item for item in settings_router._provider_choices()["llm"]}

View File

@@ -557,6 +557,7 @@ def test_registered_cloud_openai_compat_providers_enable_native_tools() -> None:
"aihubmix",
"atlascloud",
"unifically",
"cheaperinference",
"edenai",
"novita",
"volcengine_coding_plan",

View File

@@ -295,6 +295,57 @@ def test_llm_unifically_base_url_detection_preserves_openai_binding_compatibilit
assert resolved.effective_url == "https://api.unifically.com/v1"
def test_llm_cheaperinference_binding_uses_default_openai_compatible_endpoint() -> None:
catalog = _build_catalog(
llm_profile={
"id": "llm-p",
"name": "Cheaper Inference",
"binding": "cheaperinference",
"base_url": "",
"api_key": "cheaperinference-key",
"api_version": "",
"extra_headers": {},
"models": [
{
"id": "llm-m",
"name": "GPT-5.4",
"model": "gpt-5.4",
}
],
}
)
resolved = resolve_llm_runtime_config(catalog=catalog)
assert resolved.provider_name == "cheaperinference"
assert resolved.provider_mode == "gateway"
assert resolved.binding == "cheaperinference"
assert resolved.model == "gpt-5.4"
assert resolved.api_key == "cheaperinference-key"
assert resolved.effective_url == "https://api.cheaperinference.com/v1"
def test_llm_cheaperinference_base_url_detection_preserves_openai_binding_compatibility() -> None:
catalog = _build_catalog(
llm_profile={
"id": "llm-p",
"name": "OpenAI Compatible",
"binding": "openai",
"base_url": "https://api.cheaperinference.com/v1",
"api_key": "cheaperinference-key",
"api_version": "",
"extra_headers": {},
"models": [{"id": "llm-m", "name": "GPT", "model": "gpt-5.4-mini"}],
}
)
resolved = resolve_llm_runtime_config(catalog=catalog)
assert resolved.provider_name == "cheaperinference"
assert resolved.provider_mode == "gateway"
assert resolved.effective_url == "https://api.cheaperinference.com/v1"
def test_llm_novita_binding_uses_default_openai_compatible_endpoint() -> None:
catalog = _build_catalog(
llm_profile={

View File

@@ -65,6 +65,20 @@ def test_unifically_provider_lookup_and_base_detection() -> None:
assert find_gateway(api_base="https://api.unifically.com/v1") == spec
def test_cheaperinference_provider_aliases_and_base_detection() -> None:
spec = find_by_name("cheaperinference")
assert spec is not None
assert spec.display_name == "Cheaper Inference"
assert spec.env_key == "CHEAPER_INFERENCE_API_KEY"
assert spec.backend == "openai_compat"
assert spec.mode == "gateway"
assert spec.default_api_base == "https://api.cheaperinference.com/v1"
assert find_by_name("cheaper-inference") == spec
assert find_by_name("cheaper_inference") == spec
assert find_gateway(api_base="https://api.cheaperinference.com/v1") == spec
def test_openai_codex_is_not_detected_from_api_base() -> None:
assert find_gateway(api_base="https://codex.example.com/v1") is None