def get_api_call_path(request: fastapi.Request) -> str:
    """
    Extracts the API call path from the request URL.

    If the URL (without query parameters) ends with "{API_PREFIX}/queue/join", that exact path is returned.
    Otherwise, if the URL contains "{API_PREFIX}/call", the substring starting from "{API_PREFIX}/call" is returned.
    This allows for dynamic API calls to methods other than "predict".

    Raises:
        ValueError: If the request URL does not match any recognized API call pattern.
    """
    queue_api_url = f"{API_PREFIX}/queue/join"
    generic_api_url = f"{API_PREFIX}/call"
    request_path = request.url.path.rstrip("/")

    if request_path.endswith(queue_api_url):
        return queue_api_url

    start_index = request_path.rfind(generic_api_url)
    if start_index >= 0:
        return request_path[start_index : len(request_path)]

    raise ValueError(
        f"Request url '{str(request.url)}' has an unknown api call pattern."
    )

    Extracts the API call path from the request URL.

    If the URL (without query parameters) ends with "{API_PREFIX}/queue/join", that exact path is returned.
    Otherwise, if the URL contains "{API_PREFIX}/call", the substring starting from "{API_PREFIX}/call" is returned.
    This allows for dynamic API calls to methods other than "predict".

    Raises:
        ValueError: If the request URL does not match any recognized API call pattern.
    
gradio/route_utils.py