I was looking into this last year when I developed my autoblogging tool to correct the AI output. Thought about using Grammarly to autocorrect errors, and Quillbot to make the texts look less AI. I didn't find anything to automate Grammarly like that, but Quillbot has an API that you could use if you know some Python, e.g. I decided against it in the end and didn't implement it.