Artificial Intelligence
Drafts extensible platform makes it a great way to work with a variety of AI tools, both through REST APIs and directly on-device with Apple’s own Foundation Models.
Table of Contents
Online AI Services
Note
Drafts provides integration points with a number of APIs, but in most cases you will need to use your own API key and account. For more details, see linked integration guides for each service below.
Integrating with LLMs provided by large players in AI, like OpenAI and Google, can provide useful actions for getting answers to prompts, or manipulating text you have captured in Drafts…or even getting chat responses to world-knowledge questions.
Currently, Drafts supports integration with the following platforms. Follow the links for integration guides and example actions for each:
- OpenAI - ChatGPT
- Google Gemini
- Anthropic Claude
- Perplexity.ai: Note, that Perplexity supports the same API as OpenAI, so the example integrations are part of that article. See the Perplexity heading for details.
Note that other platforms which utilize the OpenAI API (like xAI and Deepseek) can also be integrated using the OpenAI
script object.
If a particular AI tool is available through web-based APIs, but is not already integrated into Drafts, you will likely find it is possible to integrate directly using scripting and Drafts’ HTTP
object – or you may find available examples by searching the directory.
On-Device AI (Foundation Models)
Requirements
Using on-device model integration requires Drafts 48 or better, running on a device (iOS, iPadOS, macOS) which supports and has enabled Apple Intelligence, running OS 26 or greater.
Starting with the version 26 releases of iOS, iPadOS, and macOS, Apple also provides private, on-device Foundation Models. These models are more focused and not suitable all the same tasks, such as answering world-knowledge questions, as larger, server side models, but they are fast and private, and work great for smaller tasks – such as summarizing text, suggesting tags, and correcting grammar.
Integration with Foundation Models is provided through scripts using the SystemLanguageModel
object.
Some example actions that demonstrate use cases:
- Ask Model: Mostly a debugging tool, the action asks you for a prompt, submits it to the model and displays a reply.
- Suggest Tags: Ask the local model to analyze the text of the current draft and suggest organizational tags to assign, then prompts you to select from those suggestions.
- Summarize Draft: Prompt model to provide a short summary of the content of the current draft, then displays it.
- Modify Selection: Prompt for text transformations description, and apply that transformation to the selected text in the editor, replacing the selection with the result.
- Random Numbers: Asks the local, on-device model to generate an array of random integer numbers. Not terribly useful in an of itself, but provided as an example of ways to retreive structured data from the model.
Drafts Data in Foundation Models
The local Foundation Models support the concept of “Tools” which provide the model access to application data to assist in answering questions. Currently, Drafts provides two experimental “tools” to allow the model to respond to inqueries about your drafts and workspaces.
We are still experimenting with the capabilities and limitations of tools, and would be happy to hear feedback about their use. For now, basic queries about draft content and tags are supported, like “Do I have any drafts which contain the text ‘Hello’?”, or “Do I have drafts with the tag ‘foo’?”
The “Ask Model” example above demonstrates including tools in the model configuration and can be used to test prompts.