xtekky/gpt4free · warning · RuntimeError
Failed to find quota information in Ollama settings page.
Error message
Failed to find quota information in Ollama settings page.
What it means
RuntimeError raised at the end of the Ollama quota scraper: the settings page was fetched and parsed without exceptions, but the quota dict is still empty — none of the expected markers ('Session usage', 'Hourly usage', 'Weekly usage', premium-request counters) matched in the HTML. This is a silent-layout-change detector: the page loaded, but it does not contain the quota sections in the shape the regexes expect (or the page is a login/landing page that dodged the form heuristics of error 91).
Source
Thrown at g4f/Provider/local/Ollama.py:118
"reset_time": reset_time,
}
match = re.search(
r'<span class="text-sm">Premium requests</span>\s*<span class="text-sm">(\d+)/(\d+) used</span>\s*</div>',
html,
)
if match:
used = int(match.group(1))
total = int(match.group(2))
pct = (used / total) * 100 if total > 0 else None
quota["premium_requests"] = {
"used": used,
"total": total,
"used_percent": pct,
}
except Exception as e:
raise RuntimeError(f"Failed to get quota information from Ollama: {e}")
if not quota:
raise RuntimeError(
"Failed to find quota information in Ollama settings page."
)
return quota
@classmethod
def get_models(cls, api_key: str = None, base_url: str = None, **kwargs):
if not cls.models:
cls.models = []
if not api_key or AppConfig.disable_custom_api_key:
api_key = AuthManager.load_api_key(cls)
models = requests.get(
"https://ollama.com/api/tags", timeout=kwargs.get("timeout", 15)
).json()["models"]
if models:
cls.live += 1
cls.models = [model["name"] for model in models]
if base_url is None:
host = os.getenv("OLLAMA_HOST", "localhost")View on GitHub (pinned to 973504e177)
Solutions
- Fetch https://ollama.com/settings with your session cookie via curl and confirm the quota section labels actually appear in the HTML.
- Verify the session cookie is valid — an auth-redirect page contains no quota markup (see error 91).
- If markup changed, update the label list and regexes in Ollama.py's quota scraper to the new page structure.
- Treat quota info as non-critical where possible: wrap the quota call and degrade gracefully rather than failing the whole request.
Example fix
# before
quota = await Ollama.get_quota(api_key) # raises RuntimeError when page layout changed
# after (degrade gracefully — quota is informational)
try:
quota = await Ollama.get_quota(api_key)
except RuntimeError as e:
logger.warning(f"Quota unavailable: {e}")
quota = None Defensive patterns
Strategy: fallback
Try / catch
try:
quota = await Ollama.get_quota(...)
except RuntimeError as e:
if 'find quota information' in str(e):
quota = None # page layout drifted; skip quota display rather than crash
else:
raise Prevention
- Never make quota scraping a hard dependency of request handling.
- Monitor ollama.com markup changes if you depend on quota numbers.
- Distinguish this 'parsed but empty' case from the exception-wrapped case (error 92) in handlers.
When it happens
Trigger: ollama.com redesigning the settings page (labels changed, percentages moved from text to CSS width bars, sections renamed) so every regex misses; the served page being an A/B variant, a consent interstitial, or a post-login redirect stub with no quota markup; a logged-out page that lacks form heuristics but also lacks quota data.
Common situations: g4f's Ollama scraper aging out after an ollama.com frontend release; region/language variants of the settings page; viewing quota via a different account type (none/pricing page) with no usage section.
Related errors
- Failed to get quota information from Ollama: {e}
- No response
- Failed to extract nonce from PhindAi response
- Failed to decode JSON from PhindAi response: {text}
- PhindAi API returned success=False: {data}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/d11bf5cd9fabc25e.
Report an issue: GitHub.