I built an Apple Shortcut that asks me for a prompt, sends it to Google’s image model through the Gemini API, and saves the picture to a file. Here are the steps in the order I set them up.
The shortcut, step by step
- Add Ask for Input and make it a text prompt.
- Add a step that uses Apple Intelligence to turn the prompt into an SEO-friendly filename. You will use this when saving the file.
- Add Get Contents of URL. Set the method to POST and paste the API URL from the video description.
- Add a header named
X-Goog-Api-Keyand paste your API key as the value. You create the key at aistudio.google.com. - Set the request body to JSON. It has an
instancesarray containing your prompt, plus aparameterssection for things like aspect ratio and sample count. - Add Get Dictionary Value and read
predictions.1.bytesBase64Encoded. - Add Base64 Decode and turn the result into an image.
- Add Save File and use the filename from step 2.
Cost
Four images cost me about 20 cents. If you only need one, set the sample count to 1. Check Google’s current pricing before you run it in bulk.
Common mistakes
The key goes in the X-Goog-Api-Key header, not in an Authorization header. And the key comes from aistudio.google.com, so double check the domain when you copy it.
This post may contain affiliate links. These links are marked with an * and I may earn a commission from qualifying purchases.