The tool avbtool have a nice interface for integrating it into third-party scripts:
avb = avbtool.Avb() # Do stuff: avb.info_image(), avb.add_hashtree_footer(), ...
However it currently only targets Python 2 (as of android-9.0.0_r3), which is unfortunate for scripts written in Python 3, forcing them to rely on e.g. the subprocess module in order to be able to use avbtool. The amount of modifications required for having avbtool compatible with Python 3 is small and requires little efforts (it's mainly about adopting Python 3's print style).