unclecode/crawl4ai · error · AttributeError

Setting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}

Error message

Setting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}

What it means

Raised by LLMExtractionStrategy.__setattr__ when you assign a value to provider, api_token, base_url, or api_base and that value differs from the __init__ default. These per-instance attributes are deprecated; the check intercepts any non-default assignment so old code that sets strategy.provider = '...' fails fast with guidance to use llm_config=LLMConfig(...).

Source

Thrown at crawl4ai/extraction_strategy.py:637

            self.chunk_token_threshold = 1e9
        self.verbose = verbose
        self.usages = []  # Store individual usages
        self.total_usage = TokenUsage()  # Accumulated usage

        self.provider = provider
        self.api_token = api_token
        self.base_url = base_url
        self.api_base = api_base

    
    def __setattr__(self, name, value):
        """Handle attribute setting."""
        # TODO: Planning to set properties dynamically based on the __init__ signature
        sig = inspect.signature(self.__init__)
        all_params = sig.parameters  # Dictionary of parameter names and their details

        if name in self._UNWANTED_PROPS and value is not all_params[name].default:
            raise AttributeError(f"Setting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}")
        
        super().__setattr__(name, value)  
        
    def extract(self, url: str, ix: int, html: str) -> List[Dict[str, Any]]:
        """
        Extract meaningful blocks or chunks from the given HTML using an LLM.

        How it works:
        1. Construct a prompt with variables.
        2. Make a request to the LLM using the prompt.
        3. Parse the response and extract blocks or chunks.

        Args:
            url: The URL of the webpage.
            ix: Index of the block.
            html: The HTML content of the webpage.

        Returns:

View on GitHub (pinned to 7e80152142)

Solutions

  1. Move all LLM settings into LLMConfig: LLMDExtractionStrategy(llm_config=LLMConfig(provider='openai/gpt-4o', api_token='...'))
  2. Remove any post-construction assignments like strategy.provider = ...
  3. Keep llm_config in one place (e.g. env-driven) and reuse it across strategies

Example fix

// before
strategy = LLMExtractionStrategy(provider="openai/gpt-4o", api_token=token)
# AttributeError: Setting 'provider' is deprecated

// after
from crawl4ai import LLMConfig
strategy = LLMExtractionStrategy(llm_config=LLMConfig(provider="openai/gpt-4o", api_token=token))
Defensive patterns

Strategy: validation

Validate before calling

from crawl4ai.async_configs import LLMConfig

# build the single config object; never set provider/api_token on the strategy
llm_config = LLMConfig(provider="openai/gpt-4o", api_token=os.environ["OPENAI_API_KEY"])
strategy = LLMExtractionStrategy(llm_config=llm_config, instruction="...")

Try / catch

try:
    strategy = LLMExtractionStrategy(llm_config=cfg, instruction=ins)
except AttributeError as e:
    if "deprecated" in str(e):
        migrate_to_llm_config()  # strip provider/api_token kwargs and rebuild
    raise

Prevention

When it happens

Trigger: strategy.provider = 'openai/gpt-4o' or passing provider='...' to __init__ with a non-default value; similarly for api_token, base_url, api_base. The AttributeError fires at assignment time (including during __init__), not at extraction time.

Common situations: Code written for crawl4ai < 0.5 that configured LLM strategies with individual constructor kwargs; tutorials showing strategy.api_token = os.environ['OPENAI_API_KEY'].

Related errors


AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14). Data as JSON: /api/errors/8f501d5961926b20. Report an issue: GitHub.