Function saveGif() is a exclusive p5*js API feature.
But if you’re on P3, there’s this library we can install from “Contribution Manager” called GifAnimation, which has a GifMaker class:
Once installed, I believe it can be imported on Python Mode like this:
add_library('gifAnimation')
from gifAnimation import GifMaker
Maybe the explicit from gifAnimation import GifMaker
isn’t needed, just add_library('gifAnimation')
would be enough.
You can also try out PyScript + p5*js if somehow GifAnimation doesn’t work for you: