Skip to content

Getting started

This guide installs anki-llm, connects it to an OpenAI model, creates a workspace, and generates one candidate card without changing your collection.

Choose one installation path.

Terminal window
curl -fsSL https://raw.githubusercontent.com/raine/anki-llm/main/scripts/install.sh | bash
Terminal window
brew install raine/anki-llm/anki-llm
Terminal window
cargo install anki-llm

Confirm that the command is available:

Terminal window
anki-llm --version

Install the AnkiConnect add-on in Anki Desktop, then restart Anki. Keep Anki running while a command reads or modifies your collection.

anki-llm uses AnkiConnect’s local HTTP API to discover decks and note types, export and update notes, add generated cards, upload media, and manage card templates. process-file can run with Anki closed once you have exported the input file.

Test the connection:

Terminal window
anki-llm query version

A JSON version number means the connection works. See AnkiConnect for connection settings and troubleshooting.

Create an OpenAI API key, then expose it to anki-llm in your shell:

Terminal window
export OPENAI_API_KEY="your-api-key-here"

OpenAI models are detected from their names, so this provider needs no base URL. Store a default model if you do not want to pass --model on each command:

Terminal window
anki-llm config set model gpt-5-mini

Run the environment diagnostic:

Terminal window
anki-llm doctor

doctor reports the detected key, resolved model, active workspace, and AnkiConnect status. Provider keys are secrets. Keep them in environment variables or a secret manager rather than prompt files or version control.

For Gemini, OpenRouter, Ollama, and other compatible endpoints, see Models and Configuration.

A workspace keeps prompts, note-type files, and model settings together. Create one in a directory you can put under version control:

Terminal window
mkdir my-anki-workspace
cd my-anki-workspace
anki-llm workspace init

This creates:

my-anki-workspace/
├── anki-llm.yaml
└── prompts/

Check what anki-llm resolved:

Terminal window
anki-llm workspace info

Run the prompt wizard:

Terminal window
anki-llm generate-init

Choose a deck and note type. The wizard samples your existing cards, asks the LLM to infer their shape and style, and saves a generated prompt under prompts/. Review that file before using it. Its frontmatter identifies the Anki deck, note type, and field mapping, while its body controls generated content.

Generate one card without importing it:

Terminal window
anki-llm generate "a term from your subject" --count 1 --dry-run

This command calls the model and prints the generated card, but --dry-run prevents the normal selection and import flow. Inspect the content, field mapping, and formatting. Edit the prompt and repeat until the result fits your deck.

When the output is ready, remove --dry-run to open the selection interface:

Terminal window
anki-llm generate "a term from your subject" --count 3

Review each candidate and import only the cards you select.