diff --git a/CHANGELOG.md b/CHANGELOG.md index 5356a9f74..d976528e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [2.3.0-beta.1](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v2.2.4-beta.1...v2.3.0-beta.1) (2026-09-25) + + +### Features + +* **models:** add Cheaper Inference OpenAI-compatible model wrapper ([2dcc16e](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/2dcc16e65fa8914cab2cc5ffa0129e0dabc92861)) +* **models:** add Cheaper Inference OpenAI-compatible model wrapper ([b6dd13e](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/b6dd13e57aa3aea57cc6bb5dc66de41e231b28af)) + ## [2.2.4](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v2.2.3...v2.2.4) (2026-09-07) @@ -16,6 +24,7 @@ * **release:** 2.2.0-beta.9 [skip ci] ([3047ef8](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/3047ef8eda694d19c6fe4654777ea6343744acba)) * **release:** 2.2.4-beta.1 [skip ci] ([8b3a97c](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/8b3a97c3b41aec29df0512e71f186a98ad747aa1)), closes [#1102](https://github.com/ScrapeGraphAI/Scrapegraph-ai/issues/1102) [#1102](https://github.com/ScrapeGraphAI/Scrapegraph-ai/issues/1102) [#1102](https://github.com/ScrapeGraphAI/Scrapegraph-ai/issues/1102) [#1102](https://github.com/ScrapeGraphAI/Scrapegraph-ai/issues/1102) + ## [2.2.4-beta.1](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v2.2.3...v2.2.4-beta.1) (2026-09-07) diff --git a/pyproject.toml b/pyproject.toml index c0673fb0b..afad4ece5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "scrapegraphai" -version = "2.2.4" +version = "2.3.0b1" description = "A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines." authors = [ diff --git a/scrapegraphai/helpers/models_tokens.py b/scrapegraphai/helpers/models_tokens.py index e64b1225b..5a81ecaa7 100644 --- a/scrapegraphai/helpers/models_tokens.py +++ b/scrapegraphai/helpers/models_tokens.py @@ -348,6 +348,10 @@ "deepseek-ai/deepseek-v4-pro": 1048576, "qwen/qwen3.5-flash": 1000000, }, + "cheaperinference": { + "gpt-5.4-mini": 400000, + "gpt-5.4": 1000000, + }, "deepseek": { "deepseek-chat": 128000, "deepseek-coder": 128000, diff --git a/scrapegraphai/models/__init__.py b/scrapegraphai/models/__init__.py index 1cbf0e06d..db01cd2e4 100644 --- a/scrapegraphai/models/__init__.py +++ b/scrapegraphai/models/__init__.py @@ -3,6 +3,7 @@ """ from .atlascloud import AtlasCloud +from .cheaperinference import CheaperInference from .clod import CLoD from .deepseek import DeepSeek from .minimax import MiniMax @@ -12,4 +13,4 @@ from .openai_tts import OpenAITextToSpeech from .xai import XAI -__all__ = ["AtlasCloud", "DeepSeek", "MiniMax", "OneApi", "OpenAIImageToText", "OpenAITextToSpeech", "CLoD", "XAI", "Nvidia"] +__all__ = ["AtlasCloud", "CheaperInference", "DeepSeek", "MiniMax", "OneApi", "OpenAIImageToText", "OpenAITextToSpeech", "CLoD", "XAI", "Nvidia"] diff --git a/scrapegraphai/models/cheaperinference.py b/scrapegraphai/models/cheaperinference.py new file mode 100644 index 000000000..423d2cfec --- /dev/null +++ b/scrapegraphai/models/cheaperinference.py @@ -0,0 +1,22 @@ +""" +Cheaper Inference Module +""" + +from langchain_openai import ChatOpenAI + + +class CheaperInference(ChatOpenAI): + """ + A wrapper for ChatOpenAI configured for Cheaper Inference's OpenAI-compatible + LLM API. Each model costs 15–60% less than the list price of its lab. + + Args: + llm_config (dict): Configuration parameters for the language model. + """ + + def __init__(self, **llm_config): + if "api_key" in llm_config: + llm_config["openai_api_key"] = llm_config.pop("api_key") + llm_config["openai_api_base"] = "https://api.cheaperinference.com/v1" + + super().__init__(**llm_config) diff --git a/tests/test_cheaperinference_model.py b/tests/test_cheaperinference_model.py new file mode 100644 index 000000000..ba9413ec8 --- /dev/null +++ b/tests/test_cheaperinference_model.py @@ -0,0 +1,50 @@ +"""Tests for Cheaper Inference model configuration.""" + +import importlib.util +import os + + +def test_cheaperinference_model_sets_openai_compatible_base_url(): + """CheaperInference should map api_key and set its base URL.""" + spec = importlib.util.spec_from_file_location( + "cheaperinference", + os.path.join( + os.path.dirname(__file__), + "..", + "scrapegraphai", + "models", + "cheaperinference.py", + ), + ) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + model = module.CheaperInference( + api_key="test-key", + model="gpt-5.4-mini", + ) + + assert ( + str(model.openai_api_base).rstrip("/") == "https://api.cheaperinference.com/v1" + ) + assert model.openai_api_key.get_secret_value() == "test-key" + + +def test_cheaperinference_models_in_token_list(): + """Cheaper Inference defaults should be listed with current context lengths.""" + spec = importlib.util.spec_from_file_location( + "models_tokens", + os.path.join( + os.path.dirname(__file__), + "..", + "scrapegraphai", + "helpers", + "models_tokens.py", + ), + ) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + cheaperinference_models = module.models_tokens["cheaperinference"] + assert cheaperinference_models["gpt-5.4-mini"] == 400000 + assert cheaperinference_models["gpt-5.4"] == 1000000