You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- extend LLMConfig with backoff delay/attempt/factor fields and thread them
through LLMExtractionStrategy, LLMContentFilter, table extraction, and
Docker API handlers
- expose the backoff parameter knobs on perform_completion_with_backoff/aperform_completion_with_backoff
and document them in the md_v2 guides
Copy file name to clipboardExpand all lines: docs/md_v2/api/parameters.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -439,10 +439,19 @@ LLMConfig is useful to pass LLM provider config to strategies and functions that
439
439
| **`provider`** | `"ollama/llama3","groq/llama3-70b-8192","groq/llama3-8b-8192", "openai/gpt-4o-mini" ,"openai/gpt-4o","openai/o1-mini","openai/o1-preview","openai/o3-mini","openai/o3-mini-high","anthropic/claude-3-haiku-20240307","anthropic/claude-3-opus-20240229","anthropic/claude-3-sonnet-20240229","anthropic/claude-3-5-sonnet-20240620","gemini/gemini-pro","gemini/gemini-1.5-pro","gemini/gemini-2.0-flash","gemini/gemini-2.0-flash-exp","gemini/gemini-2.0-flash-lite-preview-02-05","deepseek/deepseek-chat"`<br/>*(default: `"openai/gpt-4o-mini"`)* | Which LLM provider to use.
440
440
| **`api_token`** |1.Optional. When not provided explicitly, api_token will be read from environment variables based on provider. For example: If a gemini model is passed as provider then,`"GEMINI_API_KEY"` will be read from environment variables <br/> 2. API token of LLM provider <br/> eg: `api_token = "gsk_1ClHGGJ7Lpn4WGybR7vNWGdyb3FY7zXEw3SCiy0BAVM9lL8CQv"` <br/> 3. Environment variable - use with prefix "env:" <br/> eg:`api_token = "env: GROQ_API_KEY"` | API token to use for the given provider
441
441
| **`base_url`** |Optional. Custom API endpoint | If your provider has a custom endpoint
442
+
| **`backoff_base_delay`** |Optional. `int`*(default: `2`)* | Seconds to wait before the first retry when the provider throttles a request.
443
+
| **`backoff_max_attempts`** |Optional. `int`*(default: `3`)* | Total tries (initial call + retries) before surfacing an error.
444
+
| **`backoff_exponential_factor`** |Optional. `int`*(default: `2`)* | Multiplier that increases the wait time for each retry (`delay = base_delay * factor^attempt`).
-`backoff_base_delay`*(default `2` seconds)* – how long to pause before the first retry if the provider rate-limits you.
1599
+
-`backoff_max_attempts`*(default `3`)* – total tries for the same prompt (initial call + retries).
1600
+
-`backoff_exponential_factor`*(default `2`)* – how quickly the pause grows between retries. A factor of 2 yields waits like 2s → 4s → 8s.
1601
+
- Because these plug into Crawl4AI’s retry helper, every LLM strategy automatically follows the pacing you define here.
1602
+
```python
1603
+
llm_config = LLMConfig(
1604
+
provider="openai/gpt-4o-mini",
1605
+
api_token=os.getenv("OPENAI_API_KEY"),
1606
+
backoff_base_delay=1, # optional
1607
+
backoff_max_attempts=5, # optional
1608
+
backoff_exponential_factor=3, # optional
1609
+
)
1598
1610
```
1599
1611
## 4. Putting It All Together
1600
1612
In a typical scenario, you define **one**`BrowserConfig`for your crawler session, then create **one or more**`CrawlerRunConfig`&`LLMConfig` depending on each call's needs:
Copy file name to clipboardExpand all lines: docs/md_v2/core/browser-crawler-config.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -308,8 +308,20 @@ The `clone()` method:
308
308
3.⠀**`base_url`**:
309
309
- If your provider has a custom endpoint
310
310
311
+
4.⠀**Retry/backoff controls***(optional)*:
312
+
-`backoff_base_delay`*(default `2` seconds)* – base delay inserted before the first retry when the provider returns a rate-limit response.
313
+
-`backoff_max_attempts`*(default `3`)* – total number of attempts (initial call plus retries) before the request is surfaced as an error.
314
+
-`backoff_exponential_factor`*(default `2`)* – growth rate for the retry delay (`delay = base_delay * factor^attempt`).
315
+
- These values are forwarded to the shared `perform_completion_with_backoff` helper, ensuring every strategy that consumes your `LLMConfig` honors the same throttling policy.
0 commit comments