Skip to main content

ankirai

暗記 (anki) · memorization  ·  雷 (rai) · lightning

Transform your notes into Anki flashcards at lightning speed using any LLM provider.

Installation

ankirai is available on PyPI. Requires Python 3.13+.

# Recommended — installs into an isolated environment managed by uv
uv tool install ankirai

# Or with pip
pip install ankirai

Or run directly from source:

git clone https://github.com/weavergoldman/ankirai
cd ankirai
uv run ankirai --help

Quick start

ankirai init                          # first-time setup: pick provider and enter API key
ankirai generate notes.pdf            # generate an Anki deck (.apkg)
ankirai generate notes.pdf --review   # review cards in the browser before exporting

I recommend using Google's AI Studio for your API key, since the free usage limit for Gemini 3.1 Flash Lite (the default Gemini model) is quite generous.

Commands

ankirai init

Interactive setup. Stores your provider and API key in a platform config file (chmod 600). Run once before your first generate.

ankirai generate [OPTIONS] INPUTS...

Parse one or more input files and generate an Anki deck.

Option Description
--deck, -d Deck name (default: first filename stem)
--model, -m Model override
--provider, -p Provider override (gemini, openai, openrouter, ollama)
--api-key API key override
--format Output format: apkg (default), csv, tsv
--output, -o Output file path
--batch-size Cards per LLM request
--force Ignore manifest; reprocess all input files
--tags Comma-separated tags to add to all cards
--vision / --no-vision Override vision capability detection
--parsing-model Use a separate model for image/PDF parsing
--prompt Path to a custom prompt file
--review Open browser review UI before exporting
--dry-run Print extracted text chunks to stdout; skip generation and export
--instruct, -i Extra instructions surrounded by quotes, appended to the active prompt for this run

ankirai config show

Print current config with API keys redacted.

ankirai config set KEY VALUE

Update a single config value, e.g.:

ankirai config set openai.api_key sk-...
ankirai config set providers.default openrouter

ankirai prompt show

Print the currently active card-generation prompt.

ankirai prompt edit

Open the global prompt in $EDITOR.

ankirai prompt reset

Restore the built-in default prompt.

Providers

Provider Key name Default model
gemini GEMINI_API_KEY gemini-3.1-flash-lite
openai OPENAI_API_KEY gpt-5.4-nano
openrouter OPENROUTER_API_KEY google/gemini-3.1-flash-lite
ollama (none) llama4

Claude / Anthropic models: Use OpenRouter with --provider openrouter --model anthropic/claude-haiku-4-5.

API keys can also be set via environment variables or a .env file in the working directory.

Config resolution

For each setting, the first value found wins:

  1. CLI flag
  2. Environment variable
  3. .env file
  4. config.toml (platform config dir)
  5. Built-in default

Custom prompts

Prompt resolution order:

  1. --prompt <file> flag
  2. ankirai_prompt.md in the current working directory
  3. Global prompt file (ankirai prompt edit)
  4. Built-in default

The prompt should include {{notes}} where the chunk text will be substituted. Cards support LaTeX using MathJax syntax (\(...\) inline, \[...\] block). Cloze cards use {{c1::term}} syntax.

Review UI

--review launches a local web server at http://localhost:5173 and opens your browser.

Card view — keyboard shortcuts:

Key Action
1 Accept
2 Edit (inline)
3 Reject
[ or ← Previous card
] or → Next card

Bulk view — shows all cards in a paginated table (50 per page). Use the "View" button on any row to jump to that card. Use "Accept all pending" to approve everything at once.

The nav bar shows "Card view" when on the bulk page and "Bulk view" when reviewing card-by-card.

Only accepted cards are included in the exported deck.

Manifest

ankirai tracks which files have been processed in a ankirai_manifest.json in the working directory. Re-running generate on the same inputs skips unchanged files. Use --force to reprocess everything.

Documentation

Supported input formats

Anything markitdown can parse: PDF, DOCX, PPTX, images (with vision-capable models), plain text, Markdown, and more.

Metadata

Release files for ankirai 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ankirai 0.0.4
File Size Uploaded
ankirai-0.0.4.tar.gz 199.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ankirai 0.0.4
File Interpreter ABI Platform
ankirai-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 232.5 kB

Release files / ankirai-0.0.4.tar.gz

Download URL ankirai-0.0.4.tar.gz
Size 199.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bc645d99ccc00169e6bfc31e97bc9751321bf30f8daee86198c1d9d6eb6a3c25
BLAKE2b-256 checksum
How to use checksums
c0c0e27cd50607a68a2a33c4fe672aa1a5843c6f286c0e8301c04bf0ab54602c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / ankirai-0.0.4-py3-none-any.whl

Download URL ankirai-0.0.4-py3-none-any.whl
Size 33.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54786d9e14bbacb482af2c44377c54da7b31906096b29f99a1fa396aad24fc31
BLAKE2b-256 checksum
How to use checksums
d7f2ee8dc2afdd620ad6079eeea20ef6b9f8a1a9abb6cc655f4f008c0bfa3d78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page