INNER CODE UNIT · Python
api_probe
canarybyte/veridrop · web/server.py:329
async def api_probe(
request: Request,
base_url: str = Form(...),
api_key: str = Form(...),
) -> JSONResponse:
"""Probe a relay's /v1/models for the form's pre-submit pill.
Always returns 200 with a structured payload — the frontend renders any
upstream error inline rather than as a fetch failure. Exception: a 429
is returned (with Retry-After) when the per-IP rate limit is exhausted,
so the browser can back off and the frontend can show a clear "too
many probes" pill instead of a generic upstream error.
"""
ip = _client_ip(request)
allowed, retry_after = check_rate(
ip, limit=_PROBE_RATE_LIMIT, window_s=_PROBE_RATE_WINDOW_S
)
if not allowed: