unclecode/crawl4ai · warning · AttributeError
Setting '{name}' is deprecated. {message}
Error message
Setting '{name}' is deprecated. {message} What it means
JsonElementExtractionStrategy.generate_schema() used to accept individual parameters (provider, api_token, base_url, extract_type and similar legacy kwargs). These were consolidated into an LLMConfig object, and the method now inspects locals() against _GENERATE_SCHEMA_UNWANTED_PROPS and raises AttributeError if any legacy parameter is passed with a non-None value. The message includes the offending parameter name and a migration hint.
Source
Thrown at crawl4ai/extraction_strategy.py:1818:4652
Generate extraction schema from HTML content and optional query.
Args:
html (str): The HTML content to analyze
query (str, optional): Natural language description of what data to extract
provider (str): Legacy Parameter. LLM provider to use
api_token (str): Legacy Parameter. API token for LLM provider
llm_config (LLMConfig): LLM configuration object
prompt (str, optional): Custom prompt template to use
**kwargs: Additional args passed to LLM processor
Returns:
dict: Generated schema following the JsonElementExtractionStrategy format
"""
from .prompts import JSON_SCHEMA_BUILDER
from .utils import perform_completion_with_backoff
for name, message in JsonElementExtractionStrategy._GENERATE_SCHEMA_UNWANTED_PROPS.items():
if locals()[name] is not None:
raise AttributeError(f"Setting '{name}' is deprecated. {message}")
# Use default or custom prompt
prompt_template = JSON_SCHEMA_BUILDER if schema_type == "CSS" else JSON_SCHEMA_BUILDER_XPATH
# Build the prompt
system_message = {
"role": "system",
"content": f"""You specialize in generating special JSON schemas for web scraping. This schema uses CSS or XPATH selectors to present a repetitive pattern in crawled HTML, such as a product in a product list or a search result item in a list of search results. We use this JSON schema to pass to a language model along with the HTML content to extract structured data from the HTML. The language model uses the JSON schema to extract data from the HTML and retrieve values for fields in the JSON schema, following the schema.
Generating this HTML manually is not feasible, so you need to generate the JSON schema using the HTML content. The HTML copied from the crawled website is provided below, which we believe contains the repetitive pattern.
# Schema main keys:
- name: This is the name of the schema.
- baseSelector: This is the CSS or XPATH selector that identifies the base element that contains all the repetitive patterns.
- baseFields: This is a list of fields that you extract from the base element itself.
- fields: This is a list of fields that you extract from the children of the base element. {{name, selector, type}} based on the type, you may have extra keys such as "attribute" when the type is "attribute".
# Extra Context:View on GitHub (pinned to 7e80152142)
Solutions
- Build an LLMConfig(provider=..., api_token=..., base_url=...) and pass it via the llm_config parameter instead of the flat kwargs
- Remove any of the deprecated kwargs (provider, api_token, base_url, extract_type) from your call; only prompt, schema_type, html and llm_config remain supported
- Check the installed version's _GENERATE_SCHEMA_UNWANTED_PROPS dict for the exact deprecated names and their migration messages
Example fix
// before
schema = await JsonElementExtractionStrategy.generate_schema(
html=html, provider="openai/gpt-4o", api_token=token
)
// after
from crawl4ai import LLMConfig
schema = await JsonElementExtractionStrategy.generate_schema(
html=html, llm_config=LLMConfig(provider="openai/gpt-4o", api_token=token)
) Defensive patterns
Strategy: validation
Validate before calling
from crawl4ai import LLMConfig
DEPRECATED_SCHEMA_KWARGS = {"provider", "api_token", "base_url", "extract_type"}
def build_schema_call_kwargs(prompt=None, schema_type="CSS", **legacy):
bad = DEPRECATED_SCHEMA_KWARGS & legacy.keys()
if bad:
raise TypeError(f"generate_schema no longer accepts: {bad}; wrap them in llm_config=")
llm = LLMConfig(provider=legacy.get("_provider"), api_token=legacy.get("_token"))
return {"prompt": prompt, "schema_type": schema_type, "llm_config": llm} Try / catch
try:
schema = await JsonElementExtractionStrategy.generate_schema(html, llm_config=cfg)
except AttributeError as e:
if "deprecated" in str(e):
# a legacy kwarg slipped through a wrapper; log and rebuild call with LLMConfig
raise
raise Prevention
- Audit all call sites of generate_schema for flat provider/api_token/base_url kwargs before upgrading crawl4ai
- Centralize LLM credentials in one LLMConfig construction point so legacy kwargs never reach the API
- Add a smoke test after upgrades that calls generate_schema with your production arguments
When it happens
Trigger: Calling JsonElementExtractionStrategy.generate_schema(html=..., provider="openai/gpt-4o", api_token="sk-...") or passing extract_type/base_url as standalone kwargs instead of an llm_config=LLMConfig(...) object.
Common situations: Upgrading crawl4ai from an older version where generate_schema took flat LLM parameters; copy-pasted examples or tutorials targeting the old signature; wrappers that forward **kwargs into generate_schema.
Related errors
- Setting '{name}' is deprecated. {message}
- Getting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}
- Setting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}
- Failed to generate schema: {str(e)}
- The 'markdown_v2' attribute is deprecated and has been remov
AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14).
Data as JSON: /api/errors/dccda96facfb73a9.
Report an issue: GitHub.