def METHOD_NAME(api_key: str):
    sre = re.match(API_KEY_REGEX, api_key)
    if not sre:
        raise InvalidStripeAPIKey(f"Invalid API key: {api_key!r}")
    key_type = {
        "pk": APIKeyType.publishable,
        "sk": APIKeyType.secret,
        "rk": APIKeyType.restricted,
    }.get(sre.group(1), "")
    livemode = {"test": False, "live": True}.get(sre.group(2))
    return key_type, livemode