AnkiAIUtils: A Python Suite for Enhancing Anki Flashcards with AI-Generated Explanations and Images
AI-powered tools to enhance Anki flashcards with explanations, mnemonics, illustrations, and adaptive learning for medical school and beyond
At a glance
- What is it?
- AnkiAIUtils is a collection of Python scripts that connect to a running Anki desktop application via AnkiConnect and use LLMs and image generation models to add explanations, mnemonics, illustrations, and reformulations to cards the learner struggles with. It was developed and tested through medical school and targets users who want to automate their spaced-repetition improvement loop.
- Who is it for?
- AnkiAIUtils is a good fit for medical students and other heavy Anki users who want automated AI enhancement of cards they fail repeatedly, and who are comfortable running Python scripts against a live Anki install. It is not a packaged addon with a graphical interface, and the developer explicitly states it was released hastily with some documentation that may be imprecise.
- Can I use it commercially?
- Yes, with strict conditions. AGPL-3.0 is a network copyleft licence: if people use a modified version over a network, for example as a hosted service, you must offer them its source code under the same licence.
- Is it still maintained?
- Yes. The repository last received commits 121 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
What AnkiAIUtils Does and Who It Is For
AnkiAIUtils is a suite of Python scripts that modify Anki notes in place by adding AI-generated content to cards the user has failed during reviews. The problem it addresses is specific: when a flashcard consistently fails, adding more information to that card, such as an explanation of the underlying concept, a mnemonic that links to the learner's existing knowledge, or an image that encodes the information visually, can turn a repeated failure into a lasting memory.
The project was developed and tested through medical school, where the volume of material and the importance of retention make this kind of automation practical. The scripts work by communicating with Anki's AnkiConnect plugin over a local HTTP API, reading card data, sending it to an LLM, and writing the AI-generated additions back to the note fields. All changes are logged so they can be reviewed and rolled back if needed.
The intended user is someone who maintains a large Anki deck, runs Anki on a desktop machine, and wants to automate the enhancement step rather than doing it manually after each review session. The scripts are not beginner tools. They require Python, a configured LLM provider, and comfort with running scripts from the command line.
The Five Scripts and What Each Does
The repository contains five main scripts and one helper.
illustrator.py generates AI images for cards using DALL-E 2, DALL-E 3, or Stable Diffusion. It analyses card content, identifies key concepts, generates a visual mnemonic, formats the image for optimal display, and supports generating multiple images per card.
reformulator.py rephrases existing cards while preserving cloze deletions and media. It is useful when card wording is unclear, when the learner's preferred format has evolved, or when older cards need to match a current style. The README shows it turning a poorly formed bilateral alveolar syndrome card into a grammatically complete question with a self-contained answer.
explainer.py adds AI-generated concept explanations to failed cards. mnemonics_creator.py generates mnemonic hooks, including support for the major system (a mnemonic technique that encodes numbers as consonant sounds). mnemonics_helper.py provides tools for managing a personal mnemonic library so consistent hooks are reused across cards.
anchors_to_anki.py adds content from a pre-built anchors file to relevant cards. The examples/ directory includes sample datasets for each script showing the expected input format, including anchors.json and text files for explainer, illustrator, mnemonics, and reformulator datasets.
Installing the Dependencies and Connecting to Anki
The scripts require AnkiConnect running in Anki desktop. AnkiConnect exposes a local HTTP API on port 8765 that the scripts use to read and write note fields.
Dependencies are declared in requirements.txt and cover LiteLLM, semantic similarity libraries, image processing, and Anki connectivity:
pip install -r requirements.txtKey entries include litellm>=1.34.38 for LLM provider access, py-ankiconnect>=1.1.0 for Anki connectivity, scikit-learn>=1.4.1.post1 for semantic similarity matching, and Pillow>=9.0.1 for image handling. The Stable Diffusion path requires stability-sdk, which has a note in requirements.txt that grpcio install errors may require commenting that line out.
Once dependencies are installed and AnkiConnect is active, each script is invoked directly from the command line. The examples/anki_ai_utils_tmux_launcher.sh shows a launcher pattern for running multiple scripts in parallel using tmux sessions.
LiteLLM's provider-agnostic interface means any supported provider, including OpenAI, Anthropic, or local models, can be configured without changing the scripts themselves. The LiteLLM configuration determines which model generates the explanations and mnemonics.
Adaptive Learning Through Semantic Similarity
A distinctive feature of AnkiAIUtils is its use of semantic similarity to match each card with the most relevant examples from user-provided training datasets. When the illustrator or explainer generates content for a card, it first finds the most similar examples in the dataset using cosine similarity over embeddings. Those examples then prime the LLM with context about the learner's preferred style and prior knowledge.
This means the scripts improve as the training datasets grow. A user who builds a dataset of 50 example illustrations will get more consistent and personally relevant outputs than one working with an empty starting set. The major system support in mnemonics_creator.py is another example of personalisation: it can encode numbers using phonetic links (1 as T, 3 as M, 8 as F) and apply them consistently across cards when the learner uses that technique.
Cron automation is documented as a supported pattern. Running the scripts nightly on cards reviewed and failed the previous day is the recommended workflow for building up AI-enhanced notes progressively.
Known Limitations and the State of the Release
The developer is explicit about the maturity of the release. The README states: 'I released them hastily after documenting them heavily with the help of aider. It is possible that some aspects of the documentation is slightly off or imprecise. It is also possible that some of the scripts were slightly broken during the release process.'
The scripts are not packaged as Anki addons with graphical interfaces. Using them requires running Python from the command line while Anki is open and AnkiConnect is active. The developer expresses a desire for others to package these scripts into installable addons but states they do not have time to do so themselves.
The AGPL-3.0 license has implications for derivative works: any fork or modified version distributed to others must also be open source under the same license. This is relevant to anyone who wants to package the scripts into a closed commercial Anki addon.
The last push to the repository was on 2026-06-01. There are no GitHub releases and no published PyPI package.
How AnkiAIUtils Compares to Manual Card Enhancement
The practical alternative to AnkiAIUtils is doing the enhancement manually: when you fail a card, you open ChatGPT or Claude, ask for an explanation or mnemonic, and paste it into the card. This works but scales poorly across hundreds of failed cards per week, which is common in medical school or language study.
No direct comparable open-source project packages exactly this combination of explainer, illustrator, mnemonics, and reformulator as Python scripts connected to AnkiConnect. Some Anki community tools generate cards from text but do not target the enhancement-of-existing-failed-cards problem that AnkiAIUtils addresses. The value of AnkiAIUtils is not in any individual script but in the automated connection between a review session's failures and a nightly enhancement batch.
Editorial conclusion
AnkiAIUtils is a good fit for medical students and other heavy Anki users who want automated AI enhancement of cards they fail repeatedly, and who are comfortable running Python scripts against a live Anki install. It is not a packaged addon with a graphical interface, and the developer explicitly states it was released hastily with some documentation that may be imprecise. Before adopting it, verify that AnkiConnect is running in your Anki setup and that your LiteLLM configuration points to a model you can afford to call on every failed card review.
Frequently asked questions
Does AnkiAIUtils work with any LLM provider?
Yes. AnkiAIUtils uses LiteLLM, which supports all major LLM providers. The provider is configured through LiteLLM's standard interface, so you can use OpenAI, Anthropic, local models, or any other LiteLLM-supported backend without changing the scripts.
Which image generation models does AnkiAIUtils support?
The illustrator.py script supports DALL-E 2, DALL-E 3, and Stable Diffusion. The Stable Diffusion path requires stability-sdk, which the requirements.txt notes may have grpcio install issues on some systems.
Can AnkiAIUtils run automatically without manual intervention?
Yes. The README describes using cron to run the scripts automatically on cards failed the previous day. The scripts communicate with Anki via AnkiConnect, modify note fields in place, and log all changes. The examples/anki_ai_utils_tmux_launcher.sh file shows a launcher pattern for running multiple scripts in parallel.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/thiswillbeyourgithub-ankiaiutils)