BerriAI/litellm · error · BlackForestLabsError
Rejected polling URL: scheme must be https
Error message
Rejected polling URL: scheme must be https
What it means
After submitting a Black Forest Labs (FLUX) image job, LiteLLM polls the polling_url returned by the API; assert_bfl_polling_url enforces an SSRF guard that requires the https scheme. A non-https polling_url is rejected with BlackForestLabsError(502) so signed requests and credentials are never sent over plaintext or to an attacker-influenced URL. The guard deliberately allows any bfl.ai subdomain because regional endpoints differ from the submission host.
Solutions
- If you use a custom api_base/proxy for BFL, make every URL it returns (including polling_url) use https
- Remove the custom api_base and call api.bfl.ai directly
- If this fires against the real endpoint, treat it as a compromised or misrouted upstream and investigate the response source
Defensive patterns
Strategy: try-catch
Try / catch
from litellm.llms.black_forest_labs.common_utils import BlackForestLabsError
try:
img = litellm.image(model="bedrock/...", ...) # or the BFL image route
except BlackForestLabsError as e:
if e.status_code == 502 and "polling URL" in str(e):
# server-controlled polling_url failed the https SSRF guard
log.error("BFL returned a non-https polling_url; check api_base/proxy integrity")
raise Prevention
- Call BFL directly at https api.bfl.ai rather than through custom api_base proxies
- If you stub BFL in tests, return https polling URLs on a bfl.ai host pattern
- Never disable or catch-and-ignore the guard; a rejection means the response path is untrusted
When it happens
Trigger: A BFL image/edit submission whose response contains a polling_url with http:// (or another scheme): typically a mock/stub server, a custom api_base proxy returning non-https URLs, or a tampered upstream response. The real api.bfl.ai always returns https URLs.
Common situations: Pointing api_base at a local test double for BFL, corporate proxies rewriting returned URLs to http, or an upstream that is not actually BFL.
Related errors
- Rejected polling URL: host is not within the bfl.ai domain
- BFL_API_KEY is not set. Please set it via environment…
- Compresr guardrail api_base has no host
- Compresr guardrail api_base must be http or https, got…
- DNS resolution failed for
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/6c578e538f58973d.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/black_forest_labs/common_utils.py:42
def assert_bfl_polling_url(polling_url: str) -> None:
"""Validate that a polling URL points to a BFL-controlled host.
BFL returns polling URLs on subdomains like ``gateway.bfl.ai`` that differ
from the submission host ``api.bfl.ai``. A strict same-origin check would
reject these legitimate URLs. Instead we verify the host is ``bfl.ai`` or
any subdomain of it, which keeps the SSRF guarantee (credentials only go
to BFL-controlled infrastructure) without false-positives on regional hosts.
Raises:
BlackForestLabsError: If the polling URL scheme or host is not trusted.
"""
parsed: Final = urlparse(polling_url)
host: Final = (parsed.hostname or "").lower()
if parsed.scheme != "https":
raise BlackForestLabsError(
status_code=502,
message="Rejected polling URL: scheme must be https",
)
if host != _BFL_REGISTERED_DOMAIN and not host.endswith("." + _BFL_REGISTERED_DOMAIN):
raise BlackForestLabsError(
status_code=502,
message="Rejected polling URL: host is not within the bfl.ai domain",
)
# Polling configuration
DEFAULT_POLLING_INTERVAL: Final = 1.5 # seconds
DEFAULT_MAX_POLLING_TIME: Final = 300 # 5 minutes
# Model to endpoint mapping for image edit
IMAGE_EDIT_MODELS: Final[dict[str, str]] = {
"flux-kontext-pro": "/v1/flux-kontext-pro",View on GitHub (pinned to 77b7c6c40c)