BerriAI/litellm · error · BlackForestLabsError
Rejected polling URL: host is not within the bfl.ai domain
Error message
Rejected polling URL: host is not within the bfl.ai domain
What it means
The second half of the BFL SSRF guard: after the https scheme check, the polling URL host must be exactly bfl.ai or a subdomain of it (host == 'bfl.ai' or host.endswith('.bfl.ai')). Anything else (localhost, an unrelated domain, or a suffix trick like 'notbfl.ai') raises BlackForestLabsError(502), keeping BFL credentials on BFL-controlled infrastructure only.
Solutions
- If proxying/mocking BFL, ensure the polling_url your server returns is within the bfl.ai domain, or test against the real API
- Remove the custom api_base so responses come from api.bfl.ai unchanged
- Treat a rejection from a production call as evidence the upstream response was tampered with; verify the endpoint and TLS path
Defensive patterns
Strategy: try-catch
Try / catch
from litellm.llms.black_forest_labs.common_utils import BlackForestLabsError
try:
img = litellm.image(model="bfl/flux-kontext-pro", ...)
except BlackForestLabsError as e:
if e.status_code == 502 and "bfl.ai domain" in str(e):
# polling_url host was outside bfl.ai; treat as misrouted or tampered upstream
log.error("BFL polling host rejected by SSRF guard; verify api_base and upstream")
raise Prevention
- Do not point BFL traffic at gateways that rewrite polling URLs to their own hosts
- Ensure test doubles return polling URLs under *.bfl.ai to pass the host guard
- Treat any production occurrence as a security signal: verify TLS, DNS, and the api_base chain
When it happens
Trigger: A BFL API response whose polling_url points at a host outside bfl.ai: local mock servers (http://localhost), custom api_base proxies echoing their own host, or DNS/domain tricks from a tampered response.
Common situations: Local development against a stubbed BFL API, gateways that rewrite polling URLs to their own domain, or upstream responses that are not genuinely from BFL.
Related errors
- Rejected polling URL: scheme must be https
- 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/ee8c9d0c008639ba.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/black_forest_labs/common_utils.py:48
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",
"flux-kontext-max": "/v1/flux-kontext-max",
"flux-pro-1.0-fill": "/v1/flux-pro-1.0-fill",
"flux-pro-1.0-expand": "/v1/flux-pro-1.0-expand",
}
# Model to endpoint mapping for image generationView on GitHub (pinned to 77b7c6c40c)