There is no endpoint in our public API to programmatically transform visual recipes into SQL ones in a straightforward way.
One possible workaround would be to:
1. extract the SQL query from the visual recipe by using the Recipe public API :
client = dataiku.api_client()
project = client.get_project("YOUR-PROJECT-KEY")
recipe = project.get_recipe("YOUR-RECIPE-ID")
sql = recipe.get_status().data.get("sql")
2. still with the Recipe public API, programmatically create a SQL recipe with that query and replace the visual recipe by remapping its inputs and outputs to the SQL recipe.
That being said, it is definitely not trivial to implement at scale for many projects, and it may not cover some edges, that's why I would instead recommend the slow-yet-safe visual way.
Hope this helps!