From 034cfd5b2fe03249ee62c608b1cf7fd878a11b51 Mon Sep 17 00:00:00 2001 From: Dylan Firn Date: Wed, 8 Jul 2026 10:04:32 +0100 Subject: [PATCH] fix: pop model_tokens so it is not forwarded to the model client On the plain llm-config path, _create_llm read model_tokens but never removed it from llm_params, so it was splatted into init_chat_model and forwarded to the client. With ChatOpenAI (any OpenAI-compatible base_url) this surfaced as: Completions.create() got an unexpected keyword argument 'model_tokens'. Pop the key after consuming it, matching the model_instance path which already returns before the key can leak. Co-Authored-By: Claude Opus 4.8 --- scrapegraphai/graphs/abstract_graph.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scrapegraphai/graphs/abstract_graph.py b/scrapegraphai/graphs/abstract_graph.py index d508f293..5e6b7f70 100644 --- a/scrapegraphai/graphs/abstract_graph.py +++ b/scrapegraphai/graphs/abstract_graph.py @@ -221,6 +221,9 @@ def _create_llm(self, llm_config: dict) -> object: else: self.model_token = llm_params["model_tokens"] + # Consumed by ScrapeGraphAI; must not be forwarded to the model client. + llm_params.pop("model_tokens", None) + try: if llm_params["model_provider"] not in { "oneapi",