unclecode/crawl4ai · error · AttributeError
Setting '{name}' is deprecated. {message}
Error message
Setting '{name}' is deprecated. {message} What it means
Raised by JsonElementExtractionStrategy.generate_schema when the deprecated provider or api_token keyword arguments are passed (non-None). The method checks each name in _GENERATE_SCHEMA_UNWANTED_PROPS against locals() and raises AttributeError with migration guidance to llm_config.
Source
Thrown at crawl4ai/extraction_strategy.py:1818
validation retries) are added to it in-place.
**kwargs: Additional args passed to LLM processor.
Returns:
dict: Generated schema following the JsonElementExtractionStrategy format.
Raises:
ValueError: If neither html nor url is provided.
"""
from .utils import aperform_completion_with_backoff, preprocess_html_for_schema
# Validate inputs
if html is None and (url is None or (isinstance(url, list) and len(url) == 0)):
raise ValueError("Either 'html' or 'url' must be provided")
# Check deprecated parameters
for name, message in JsonElementExtractionStrategy._GENERATE_SCHEMA_UNWANTED_PROPS.items():
if locals()[name] is not None:
raise AttributeError(f"Setting '{name}' is deprecated. {message}")
if llm_config is None:
llm_config = create_llm_config()
# Save original HTML(s) before preprocessing (for validation against real HTML)
original_htmls = []
# Fetch HTML from URL(s) if provided
if url is not None:
from .async_webcrawler import AsyncWebCrawler
from .async_configs import BrowserConfig, CrawlerRunConfig, CacheMode
browser_config = BrowserConfig(
headless=True,
text_mode=True,
light_mode=True,
)
crawler_config = CrawlerRunConfig(cache_mode=CacheMode.BYPASS)View on GitHub (pinned to 7e80152142)
Solutions
- Replace provider/api_token kwargs with llm_config=LLMConfig(provider='...', api_token='...')
- Search your codebase for generate_schema( calls using provider= or api_token= and migrate them all
Example fix
// before
schema = await JsonElementExtractionStrategy.generate_schema(
url=u, provider="openai/gpt-4o", api_token=tok) # AttributeError
// after
from crawl4ai import LLMConfig
schema = await JsonElementExtractionStrategy.generate_schema(
url=u, llm_config=LLMConfig(provider="openai/gpt-4o", api_token=tok)) Defensive patterns
Strategy: validation
Validate before calling
import inspect
banned = {"provider", "api_token"}
sig = inspect.signature(JsonElementExtractionStrategy.generate_schema)
kwargs = {k: v for k, v in my_kwargs.items() if k not in banned and k in sig.parameters}
schema = await JsonElementExtractionStrategy.generate_schema(**kwargs) Try / catch
try:
schema = await JsonElementExtractionStrategy.generate_schema(html=h, **kwargs)
except AttributeError as e:
if "deprecated" in str(e):
kwargs.pop("provider", None); kwargs.pop("api_token", None)
kwargs["llm_config"] = llm_config
schema = await JsonElementExtractionStrategy.generate_schema(html=h, **kwargs)
else:
raise Prevention
- Pass LLM settings only through llm_config in generate_schema calls
- Grep for generate_schema(.*provider= / api_token= when upgrading
When it happens
Trigger: Calling generate_schema(html=..., provider='openai/gpt-4o') or generate_schema(url=..., api_token='sk-...'). Only these two names are checked; passing them as None is tolerated.
Common situations: Old scripts from before the LLMConfig refactor that configured the schema generator per-call; copy-pasted snippets from outdated tutorials.
Related errors
- Setting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}
- LLM returned an empty response
- Failed to parse schema JSON: {str(e)}
- Failed to generate schema: {str(e)}
- Failed to generate schema: no attempts succeeded
AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14).
Data as JSON: /api/errors/db562db7415a2912.
Report an issue: GitHub.