Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ class ProvidersConfig(_Base):
openrouter: ProviderConfig = Field(default_factory=ProviderConfig)
forge: ProviderConfig = Field(default_factory=ProviderConfig)
requesty: ProviderConfig = Field(default_factory=ProviderConfig)
cheaperinference: ProviderConfig = Field(default_factory=ProviderConfig)
bedrock: ProviderConfig = Field(default_factory=ProviderConfig)
anthropic: ProviderConfig = Field(default_factory=ProviderConfig)
openai: ProviderConfig = Field(default_factory=ProviderConfig)
Expand Down
13 changes: 13 additions & 0 deletions core/providers/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ def _matches_declared_endpoint(self, api_base: str | None) -> bool:
# OpenRouter-style gateways above.
strip_model_prefix=True,
),
ProviderSpec(
name="cheaperinference",
keywords=("cheaperinference",),
env_key="CHEAPER_INFERENCE_API_KEY",
display_name="Cheaper Inference",
backend="openai_compat",
is_gateway=True,
endpoint_class="gateway",
detect_by_base_keyword="cheaperinference.com",
default_api_base="https://api.cheaperinference.com/v1",
# Cheaper Inference resolves bare model ids, like Forge.
strip_model_prefix=True,
),
ProviderSpec(
name="bedrock",
keywords=("bedrock",),
Expand Down
19 changes: 19 additions & 0 deletions docs/guide/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ This first integration sends the configured value as a bearer token through
Bedrock's OpenAI-compatible Chat Completions API. It does **not** implement AWS
SigV4 signing, IAM role/profile discovery, SSO, or the native Converse API.

### Cheaper Inference

[Cheaper Inference](https://cheaperinference.com) is an OpenAI-compatible
gateway to models from several labs. Each model costs 15–60% less than the
list price of its lab. Create a key at
[cheaperinference.com/signup](https://cheaperinference.com/signup) and expose
it through `CHEAPER_INFERENCE_API_KEY`:

```console
deepcode provider set my-cheaperinference --template cheaperinference \
--api-key-env CHEAPER_INFERENCE_API_KEY
deepcode provider models my-cheaperinference --refresh
deepcode provider test my-cheaperinference --model gpt-5.4-mini --agent
```

The template uses `https://api.cheaperinference.com/v1`. Model IDs are bare,
for example `gpt-5.4-mini`, `gpt-5.4` or `claude-sonnet-5`. Cheaper Inference
serves chat models only; it has no embeddings endpoint.

## Declared models and capacities

If your server's model is missing from the list, add it manually. You can also
Expand Down
71 changes: 71 additions & 0 deletions tests/test_cheaperinference_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Cheaper Inference gateway registration.

Cheaper Inference is an OpenAI-compatible gateway on the generic
``openai_compat`` backend. Like Forge, it resolves bare model ids.
"""

from __future__ import annotations

import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))

from core.config import DeepCodeConfig, ProvidersConfig # noqa: E402
from core.providers.credentials import CredentialStore # noqa: E402
from core.providers.model_compat import resolve_model_compat # noqa: E402
from core.providers.profiles import ConnectionResolver # noqa: E402
from core.providers.registry import find_by_name # noqa: E402


def test_cheaperinference_is_registered_as_a_gateway():
spec = find_by_name("cheaperinference")
assert spec is not None
assert spec.display_name == "Cheaper Inference"
assert spec.is_gateway is True
assert spec.endpoint_class == "gateway"
assert spec.backend == "openai_compat"
assert spec.env_key == "CHEAPER_INFERENCE_API_KEY"
assert spec.default_api_base == "https://api.cheaperinference.com/v1"


def test_cheaperinference_strips_the_vendor_prefix():
"""Cheaper Inference resolves bare model ids, like Forge."""

spec = find_by_name("cheaperinference")
assert spec.strip_model_prefix is True
compat = resolve_model_compat(
model_name="openai/gpt-5.4-mini", spec=spec, reasoning_effort=None
)
assert compat.model_name == "gpt-5.4-mini"


def test_cheaperinference_does_not_collide_with_other_gateway_detection():
spec = find_by_name("cheaperinference")
assert spec.detect_by_base_keyword == "cheaperinference.com"
assert spec.detect_by_key_prefix == ""


def test_providers_config_exposes_cheaperinference():
"""``config.py`` reads providers via ``getattr(..., spec.name)``, so a
missing field silently disables the provider everywhere."""

assert hasattr(ProvidersConfig(), "cheaperinference")


def test_cheaperinference_profile_uses_the_default_base(tmp_path: Path):
credentials = CredentialStore(tmp_path / "credentials.json")
credentials.set("my-ci", "ci-test-secret")
config = DeepCodeConfig.model_validate(
{"providers": {"profiles": {"my-ci": {"template": "cheaperinference"}}}}
)
connection = ConnectionResolver(config, credentials).resolve_connection("my-ci")

assert connection.provider_name == "cheaperinference"
assert connection.adapter == "openai_compat"
assert connection.api_base == "https://api.cheaperinference.com/v1"
assert connection.api_key == "ci-test-secret"
assert connection.model_catalog == "openai"
assert connection.is_usable is True
1 change: 1 addition & 0 deletions tests/test_provider_egress.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def test_invalid_policy_entry_fails_closed():
("openrouter", "gateway"),
("requesty", "gateway"),
("forge", "gateway"),
("cheaperinference", "gateway"),
("zhipu", "aggregator"),
("dashscope", "aggregator"),
("minimax", "aggregator"),
Expand Down