from typing import Dict
from typing import Tuple


def extract_base_url_from_spec(spec: Dict) -> Tuple[str, Dict]:
    """Extract the server urls from the spec to be used when generating functions.

    Args:
        spec: The OpenAPI Spec dictionary to extract the urls from.

    Returns:
        A tuple of the first BASE_URL (as default) and a variables dictionary that sets the BASE_URL.

    Exceptions:
        ValueError: If the spec has no URLs in its "servers" section.
    """
    if len(spec["servers"]) == 0:
        raise ValueError("No server URLs found in spec")

    base_urls = [s["url"] for s in spec["servers"]]
    variables = {"BASE_URL": base_urls[0]}
    return base_urls[0], variables