As @ABraun suggested you can invoke gpt from python as a separate process, but you can also use the API of the Graph Processing Framework.
Some examples can be found here (by @antonio19812 ):
Also these forum threads can be helpful: