We need to use a new method, probably called `generate_script_api` rather than modifying the logic of `generate_code`.