Repository navigation
A hard dollar limit per crawl job for LLMExtractionStrategy (base_url + extra_headers) #2342
domondi1
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
LLMExtractionStrategymakes one model call per chunk, so one crawl over many pages can turn into hundreds of paid calls, andresult.token_usagetells you the count afterwards. If you want a hard dollar ceiling per crawl job instead, you can do it with whatLLMConfigandextra_argsalready accept: pointbase_urlat a local gateway and send a job id plus a budget as headers. I maintain the gateway (Inferrail, open source), so weigh that accordingly.Every chunk of every page in that crawl carries the same id, so they share the $2.00, including chunks extracted in parallel. A call that would push the job past it gets HTTP 402 before it reaches OpenAI. Then:
inferrail work catalog-2026-10-06 # calls, tokens and dollars for that crawlWhat I checked (crawl4ai 0.9.4, inferrail 0.4.15, calling the strategy's
run()on a 10-chunk page against a stand-in OpenAI endpoint with fixed token counts, so no browser and no real spend):RateLimitError, so a refused chunk is tried once, not in a loop.Caveats:
inferrail models); for other providers you add a price in the gateway config. An unpriced model is refused with a clear error, not guessed.Work-Idset to the URL or page id.All reactions