Skip to content

Gib-git/trilium-ai-anki-addon

Repository files navigation

Demo Video

demo-small.mp4

See demo video here

Trilium Notes → Anki Sync Plugin

Dynamically import notes from Trilium Notes into Anki as flashcards,
with optional Ollama (local AI) powered card generation. By Gibran Ali https://gibranali.com


Installation

  1. Locate your Anki addons folder:

    • Windows: %APPDATA%\Anki2\addons21\
    • macOS: ~/Library/Application Support/Anki2/addons21/
    • Linux: ~/.local/share/Anki2/addons21/
  2. Copy the trilium_anki_addon/ folder into that directory:

    addons21/
    └── trilium_anki_addon/
        ├── __init__.py
        ├── config.json
        ├── manifest.json
        ├── addon_config.py
        ├── trilium_client.py
        ├── ollama_client.py
        ├── anki_importer.py
        ├── config_dialog.py
        └── trilium_sync.py
    
  3. Restart Anki. You should see two new entries under Tools:

    • Sync from Trilium Notes
    • Trilium Sync Settings

Setup

1. Get your Trilium ETAPI token

  1. Open Trilium → Options (top-right gear icon)
  2. Go to the ETAPI tab
  3. Click Generate new token, copy it

2. Configure the plugin

  1. In Anki: Tools → Trilium Sync Settings
  2. Set your Trilium URL (default: http://localhost:8080)
  3. Paste your ETAPI Token
  4. Click Test Connection — you should see your Trilium version

3. (Optional) Set up Ollama for AI card generation

  1. Install Ollama: https://ollama.com
  2. Pull a model: ollama pull llama3
  3. In Settings: check Ollama (Local AI), set URL + model name
  4. Click Test Ollama Connection

Usage

  1. Tools → Sync from Trilium Notes
  2. Search notes by keyword, or filter by label (e.g. #anki or #study)
  3. Select one or more notes from the list
  4. Choose generation mode:
    • Manual — note title becomes the Front, content becomes the Back
    • AI (Ollama) — Ollama generates smart Q&A cards automatically
  5. Click ⚙ Generate Preview — review and edit cards in the table
  6. Click ✅ Import to Anki

Tips

  • Tag notes in Trilium with #anki to easily filter them for import
  • Cards are deduplicated — re-importing won't create duplicates
  • All imported cards get a trilium tag (configurable in Settings)
  • The preview table is fully editable before importing
  • Works with Trilium running locally or on a server (update URL accordingly)

Troubleshooting

Problem Fix
"No Trilium token set" Go to Settings and paste your ETAPI token
Connection refused Make sure Trilium is running; check port/URL
Ollama timeout Model might be slow; try a smaller model like phi3 or mistral
Cards not appearing Check the deck name in Settings matches exactly
JSON parse error from Ollama Try a different model; some handle JSON better (llama3, mistral)

Requirements

  • Anki 2.1.50+
  • Trilium Notes 0.50+ (for ETAPI support)
  • Python 3.9+ (bundled with Anki)
  • Ollama (optional, for AI mode): https://ollama.com

About

Dynamically import notes from Trilium Notes into Anki as flashcards, with optional Ollama (local AI) powered card generation.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages