Update July 18th, 2024: I discontinued the GPT-3.5 versions of the shortcuts, no one should be using that model anymore. I’ve also upgraded everything from GPT-4 to GPT-4o and tweaked some prompts. If you prefer, you can switch to GPT-4o mini. Just edit your downloaded shortcut to make the change.

Update July 21st, 2023: I updated the downloadable extensions to the Chat Completions API (before: Completions). That’s the recommended way to go nowadays. The extensions are available for GPT-3.5 and 4. These shortcuts will only work if you’re a paying OpenAI subscriber! Otherwise you will see parsing errors.

In this blog post, I’ll walk you through using Apple Shortcuts to harness OpenAI’s Completions API in macOS and iOS to make your everyday tasks, like summarizing text, proofreading, and translating, easier and quicker. Plus, no app required – just a no-code approach to get the job done fast.

My co-worker Hermann developed a Python app, GPT-3 Companion, to streamline his workflows using GPT-3. I, on the other hand, wanted something more integrated with macOS and iOS, so I took the Shortcuts.app route.

The first step is to get an API key from OpenAI. This is a secret key that you should not share with others or expose by sharing your Apple shortcut with your co-workers or friends. You could also route your requests through your own backend server where your API key can be securely stored, but this is out of scope for this blog post.

The second step is to create a shortcut that can send an HTTP request the OpenAI Chat Completions API with the text input and the parameters. You can use the “Get Contents of URL” action in Shortcuts.app to do this. You will need to specify the URL https://api.openai.com/v1/chat/completions, the HTTP method (POST), the headers (authorization: Bearer YOUR_API_KEY), and the body (a JSON object with your text input and parameters).

The third step is to parse the response and display it in a way that suits your needs. You can use the “Get Dictionary from Input” action in your shortcut to convert the JSON response into a dictionary object that you can access. You need dig through to choices.1.message.content.

BESCHREIBUNG
BESCHREIBUNG

You can then use other actions such as “Show Result”, “Speak Text”, “Copy to Clipboard”, or “Share” to present or use the output.

Here are some examples of how I’m using shortcuts for different tasks:

Summarize text

Get a nice summary on what a piece of text is all about. Tip: You can send a long text input and set the max_tokens parameter (the maximum number of tokens in the completion) to a lower value (such as 50) to get a shorter summary of the text.

Great for long emails where no one knows what the sender wants to say.
My shortcut
My shortcut “Summarize” as shown in Shortcuts.app

Proofread text

You can send a text input with errors or typos and it’ll get fixed. Easy as that.

Edit text

Let the AI act as a professional editor, fix your mistakes, and improve your writing style.

Translate text

You can send a text input in one language and it’ll get translated to another. Most of the time this works way better than conventional translation tools like Google Translate or Apple Translate. I started with three shortcuts, one for each target language: English, German, Italian. After a while I came up with a single shortcut that asks for the desired target language with a prompt.

How do I integrate it?

The best part about using Apple Shortcuts is that you can integrate it seamlessly into your operating system. On macOS, you can access your shortcuts from the context menu via Services, which lets you select any text on any app and run your shortcut on it. On iOS, you can access your shortcuts from the Share Sheet, which lets you share any content from any app and run your shortcut on it. Oh, did I mention that shortcuts sync to all of your devices via iCloud?

Don’t forget to make the shortcut available via Share Sheet and Services
Don’t forget to make the shortcut available via Share Sheet and Services

From now on your shortcuts are in reach whereever you select text, be it a web page or a text input where it can even be replaced.

Select text on iOS/iPadOS, choose
Select text on iOS/iPadOS, choose “Share” from the tooltip menu.
The Share Sheet popping up, find your shortcuts there.
The Share Sheet popping up, find your shortcuts there.

With Apple Shortcuts and OpenAI’s Chat Completions API, you can create powerful tools for working with natural language without writing any code. Think: endless possibilities for creativity, productivity, and fun.

What happens to my data?

When using one of the shortcuts or submitting text to OpenAI’s APIs, their API data usage policies apply. As of March 8th, 2023, there are two key points to keep in mind:

OpenAI will not use data submitted by customers via our API to train or improve our models, unless you explicitly decide to share your data with us for this purpose. You can opt-in to share data.

Any data sent through the API will be retained for abuse and misuse monitoring purposes for a maximum of 30 days, after which it will be deleted (unless otherwise required by law).

It should go without saying, but: don’t send any critical, private, or confidential texts to a third-party without doing the research on how they handle this kind of data. If necessary, anonymize your text beforehand.

Download

You can download my shortcuts at Apple. When importing them you’ll be asked for your OpenAI API key. How are they working for you? Anything that needs improvement? Are the prompts not useful? What are you using OpenAI’s text APIs for? Let me know via email.

Revised: My shortcuts are now updated to use the chat completions API of GPT-4o. Note: These will only work for you if you’re a paying OpenAI subscriber.

Sorry for the header image. Couldn’t spare you the AI feet.

Technology Briefing#1: Large Language Models und Commodity AI