Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

Add Cheaper Inference as a named provider preset

aiapienthusiast934799d56025
diff --git a/docs/en/concepts/provider-system.md b/docs/en/concepts/provider-system.md
index 404b307..35624ee 100644
--- a/docs/en/concepts/provider-system.md
+++ b/docs/en/concepts/provider-system.md
@@ -1,6 +1,6 @@
# Provider System
-Hyper-Extract supports these ways to connect to LLMs: **OpenAI**, **Anthropic**, **Google Gemini**, **Alibaba Bailian**, **DeepSeek**, **OrcaRouter**, and **local vLLM**. All use the same `create_client()` interface — only the first line changes.
+Hyper-Extract supports these ways to connect to LLMs: **OpenAI**, **Anthropic**, **Google Gemini**, **Alibaba Bailian**, **DeepSeek**, **OrcaRouter**, **Cheaper Inference**, and **local vLLM**. All use the same `create_client()` interface — only the first line changes.
---
@@ -15,6 +15,7 @@ Hyper-Extract supports these ways to connect to LLMs: **OpenAI**, **Anthropic**,
| **Google Gemini** | gemini-3.8-flash / gemini-2.5-flash / gemini-2.5-pro | ✅ (tool calling) | ✅ | LLM only — no embedder path in this repo (pair with an OpenAI-compatible embedder). Needs `hyperextract[google]`. Keys: `GOOGLE_API_KEY` or `GEMINI_API_KEY`. Alias: `gemini` |
| **DeepSeek** | deepseek-v4-flash / deepseek-v4-pro | ✅ | ✅ | OpenAI-compatible. V4 models default to "thinking" mode, which Hyper-Extract auto-disables (`extra_body`) so structured extraction works. LLM only — no embeddings API. Keys: `DEEPSEEK_API_KEY` |
| **OrcaRouter** | `orcarouter/auto`, `openai/gpt-4o-mini`, `anthropic/claude-haiku-4-5`, `deepseek/...`, `gemini/...` | ✅ | ✅ | OpenAI-compatible gateway routing 150+ models from OpenAI, Anthropic, Google, DeepSeek, Qwen, MiniMax, xAI behind one endpoint and key. Keys: `ORCAROUTER_API_KEY` |
+| **Cheaper Inference** | gpt-5.4-mini | ✅ | ✅ | OpenAI-compatible gateway. One key gives access to models from several labs. LLM only — no embeddings API (pair with an OpenAI-compatible embedder). Keys: `CHEAPER_INFERENCE_API_KEY` |
| **Alibaba Bailian** | qwen-plus / qwen-turbo / qwen3.6-plus / deepseek-r1 | ✅ | ✅ | Works out of the box |
| **Alibaba Bailian** | qwen-max / deepseek-v3 | ❌ | ❌ | Only `json_object`; not compatible with function-calling structured output |
@@ -80,6 +81,14 @@ llm, emb = create_client(
# Key: ORCAROUTER_API_KEY (fallback: OPENAI_API_KEY).
llm, emb = create_client("orcarouter")
+# Cheaper Inference — OpenAI-compatible gateway, one key for models from
+# several labs. No embeddings API, so pair it with an OpenAI-compatible embedder.
+# Key: CHEAPER_INFERENCE_API_KEY. Override model with "cheaperinference:gpt-5.4".
+llm, emb = create_client(
+ llm="cheaperinference", # default model: gpt-5.4-mini
+ embedder="openai:text-embedding-3-small",
+)
+
# Local vLLM
llm, emb = create_client(
llm="vllm:Qwen3.5-9B@http://localhost:8000/v1",
diff --git a/docs/en/python/guides/provider-configuration.md b/docs/en/python/guides/provider-configuration.md
index 480f7cb..ee5a014 100644
--- a/docs/en/python/guides/provider-configuration.md
+++ b/docs/en/python/guides/provider-configuration.md
@@ -1,6 +1,6 @@
# Provider Configuration Guide
-Configure Hyper-Extract to work with OpenAI, Bailian (Alibaba Cloud), DeepSeek, OrcaRouter, or local vLLM deployments.
+Configure Hyper-Extract to work with OpenAI, Bailian (Alibaba Cloud), DeepSeek, OrcaRouter, Cheaper Inference, or local vLLM deployments.
---
@@ -64,6 +64,20 @@ llm, emb = create_client("orcarouter")
# Or override the model: create_client("orcarouter:openai/gpt-4o-mini", ...)
```
+### Cheaper Inference
+
+```python
+from hyperextract import create_client
+
+# Cheaper Inference is an OpenAI-compatible gateway with one key for models
+# from several labs. It has no embeddings API, so pair it with another embedder.
+# Key: CHEAPER_INFERENCE_API_KEY.
+llm, emb = create_client(
+ llm="cheaperinference", # default model: gpt-5.4-mini
+ embedder="openai:text-embedding-3-small",
+)
+```
+
### Local vLLM
```python
@@ -104,6 +118,7 @@ print(f"Nodes: {len(graph.nodes)}, Edges: {len(graph.edges)}")
| **Anthropic** | `he config llm -p anthropic -k sk-ant-xxx` + `he config embedder -p openai -k sk-xxx` |
| **DeepSeek** | `he config llm -p deepseek -k sk-xxx` + `he config embedder -p openai -k sk-xxx` |
| **OrcaRouter** | `he config init -p orcarouter -k sk-orca-xxx` |
+| **Cheaper Inference** | `he config llm -p cheaperinference -m gpt-5.4-mini -k ci_live_xxx` + `he config embedder -p openai -k sk-xxx` |
| **vLLM** | `he config init` → select "local vLLM" |
| **Mixed** (LLM=Bailian, Embedder=vLLM) | `he config llm -p bailian -k sk-xxx` + `he config embedder -p vllm -u http://localhost:8001/v1 -k dummy` |
diff --git a/hyperextract/utils/client.py b/hyperextract/utils/client.py
index 745575d..ef0b64d 100644
--- a/hyperextract/utils/client.py
+++ b/hyperextract/utils/client.py
@@ -63,6 +63,14 @@ PROVIDER_PRESETS: dict[str, dict[str, str | None]] = {
"default_llm": "orcarouter/auto",
"default_embedder": "openai/text-embedding-3-small",
},
+ # Cheaper Inference. OpenAI-compatible LLM gateway with one key for models
+ # from several labs, using bare model ids such as "gpt-5.4-mini". It has no
+ # embeddings API — pair it with an OpenAI-compatible embedder.
+ "cheaperinference": {
+ "base_url": "https://api.cheaperinference.com/v1",
+ "default_llm": "gpt-5.4-mini",
+ "default_embedder": None,
+ },
# Anthropic (Claude). Uses the native ChatAnthropic client, so base_url is
# left empty (the SDK targets api.anthropic.com by default). Anthropic has
# no embeddings API, hence default_embedder is None — pair it with an
@@ -113,6 +121,7 @@ PROVIDER_API_KEY_ENV: dict[str, tuple[str, ...]] = {
"gemini": ("GOOGLE_API_KEY", "GEMINI_API_KEY"),
"deepseek": ("DEEPSEEK_API_KEY",),
"orcarouter": ("ORCAROUTER_API_KEY",),
+ "cheaperinference": ("CHEAPER_INFERENCE_API_KEY",),
}
diff --git a/tests/utils/test_client.py b/tests/utils/test_client.py
index bd55c2a..49bf36a 100644
--- a/tests/utils/test_client.py
+++ b/tests/utils/test_client.py
@@ -73,6 +73,13 @@ class TestParseClientSpec:
)
assert result["model"] == "openai/text-embedding-3-small"
+ def test_provider_cheaperinference(self):
+ """Cheaper Inference preset defaults (OpenAI-compatible gateway)."""
+ result = _parse_client_spec("cheaperinference", api_key="sk-test")
+ assert result["provider"] == "cheaperinference"
+ assert result["model"] == "gpt-5.4-mini" # default_llm preset
+ assert result["base_url"] == "https://api.cheaperinference.com/v1"
+
def test_dict_input(self):
"""Dict input is passed through with api_key fallback."""
result = _parse_client_spec(
@@ -146,6 +153,19 @@ class TestCreateLLM:
llm = create_llm("orcarouter")
assert llm.openai_api_key.get_secret_value() == "sk-orca-test"
+ def test_create_llm_cheaperinference(self):
+ """Create LLM with cheaperinference preset (OpenAI-compatible gateway)."""
+ llm = create_llm("cheaperinference", api_key="sk-test")
+ assert llm.model_name == "gpt-5.4-mini"
+ assert llm.openai_api_base == "https://api.cheaperinference.com/v1"
+
+ def test_create_llm_cheaperinference_env_key(self, monkeypatch):
+ """Key is read from CHEAPER_INFERENCE_API_KEY when api_key is omitted."""
+ monkeypatch.setenv("OPENAI_API_KEY", "sk-openai-test")
+ monkeypatch.setenv("CHEAPER_INFERENCE_API_KEY", "ci-test")
+ llm = create_llm("cheaperinference")
+ assert llm.openai_api_key.get_secret_value() == "ci-test"
+
def test_create_llm_deepseek_reads_provider_env_key(self, monkeypatch):
"""create_llm('deepseek') uses DEEPSEEK_API_KEY when api_key is omitted."""
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
@@ -606,6 +626,14 @@ class TestProviderPresets:
assert preset["default_llm"] == "orcarouter/auto"
assert preset["default_embedder"] == "openai/text-embedding-3-small"
+ def test_cheaperinference_provider(self):
+ """Cheaper Inference has its own preset (OpenAI-compatible, no embeddings)."""
+ assert "cheaperinference" in PROVIDER_PRESETS
+ preset = PROVIDER_PRESETS["cheaperinference"]
+ assert preset["base_url"] == "https://api.cheaperinference.com/v1"
+ assert preset["default_llm"] == "gpt-5.4-mini"
+ assert preset["default_embedder"] is None
+
def test_all_presets_have_base_url_or_none(self):
"""Every preset has either a base_url or None (for vLLM)."""
for name, preset in PROVIDER_PRESETS.items():