ai-dictionary-koreader
Context-aware AI dictionary plugin for KOReader: instant definitions, explanations, deep dives, pronunciation, and voca…
git clone https://github.com/SahandMalaei/ai-dictionary-koreader.gitSahandMalaei/ai-dictionary-koreaderAI Dictionary: Supercharged Dictionary/Explainer for KOReader
AI Dictionary is a dictionary/explanation plugin for KOReader that can have a transformative effect on your reading and learning. I built it out of personal frustration with the dictionary solutions that are currently available, and the resulting plugin is something I use every day with my reading. The limitations of traditional dictionaries, which this project adresses, include:
- They give you multiple definitions of the same word and you need to figure out/guess which definition fits the context.
- The built-in dictionaries of ebook readers generally don't support looking up the definition of multi-part phrases and idioms.
- They can't give you the definition in the context of the book that you are reading, and might—understandably—lack the definiton for words which only make sense in the context of a book, e.g. fictional terms in a novel.
AI Dictionary gives you the meaning of your selected text in the context of its surrounding words, and also in the context of the book you are reading. You can ask for the definition of any number of words together, ask it to explain text in the context of the book, or to turn the selected text into more simplified English. All of that is available at the press of a button with no need to type anything. All the back-and-forth with the AI is done in the background, for a most seamless reading/learning experience.
How to Use
To use this plugin, you'll need to do a few things, which I've listed below.
- Get KoReader installed on your e-reader/device.
- Download the latest release of this plugin.
- The default AI provider is OpenAI's ChatGPT. Acquire an API key from the OpenAI platform. Optional: Alternatively, you can use any OpenAI-compatible AI provider of your own. I personally use OpenRouter along with Google's Gemini 2.5 Flash for the best balance between speed and accuracy. You probably need to add some credits to your account, but from experience I can tell you that the personal use of this plugin is practically free (as long as you use fast and cheap models such as GPT5-Nano or Gemini 2.5 Flash). For reference, my own personal use over seven days costs me about 2 cents.
- Once you have your API key, rename
configuration.lua.sampletoconfiguration.luaand inside it, replaceYOUR_API_KEYwith your own API key. Optional: Alternatively, you can use any OpenAI-compatible endpoint and model by setting them inconfiguration.lua. As said earlier, I personally use OpenRouter along withgoogle/gemini-2.5-flashfor the quick and accurate results. For this, you need to fill out thetext_endpointandtext_modelproperties ofconfiguration.luawith values of your own.
local CONFIGURATION = {
api_key = "YOUR_API_KEY",
text_endpoint = "https://api.openai.com/v1/chat/completions",
text_model = "gpt-5-nano"
}
return CONFIGURATION
Android-Only: The AI Dictionary popup can also show a Pronounce button on Android when AI voice output is configured. It uses the same api_key as text completion. You can use it by setting voice_endpoint, voice_model, and optionally voice_voice in configuration.lua:
voice_endpoint = "https://api.openai.com/v1/audio/speech", voice_model = "gpt-4o-mini-tts", voice_voice = "nova",
- Copy the folder named
AI_Dictionary.koplugininto thekoreader/pluginsdirectory on your device. - You'll most probably want to disable the automatic launch of KOReader's default dictionary functionality on single-word selection. To do that, open KOReader's top menu (tap on the top part of the screen), go to
Settings(the gear icon), selectLong-press on textand disableDictionary on single word selection. - You are all set! Now simply select some word(s)/text, and use one of the options the plugins gives you ("AI Dictionary", "AI Explain", "AI English Simplify") to get answers.
Sample configuration.lua
This is the configuration I personally use for the best results (don't forget to fill in your own API key):
local CONFIGURATION = {
api_key = "[YOUR_API_KEY]",
text_endpoint = "https://openrouter.ai/api/v1/chat/completions",
text_model = "google/gemini-2.5-flash",
voice_endpoint = "https://openrouter.ai/api/v1/audio/speech",
voice_model = "x-ai/grok-voice-tts-1.0",
voice_voice = "Ara"
}
return CONFIGURATION
What's Next?
I'm calling on you—the community—to help expand this plugin with features that might help others read/study/learn better. A few starters:
- The plugin is built around English-to-English dictionary lookups, though supporting other languages in the future might make sense. Making it seamless is the main challenge.
- The plugin currently keeps a local log of every dictionary lookup. I'm open to suggestions about what kinds of personalized learning material we can create for the user with that.
This plugin wouldn't have been possible without the initial backbone provided by AskGPT—an excellent plugin that lets you talk to ChatGPT directly from inside KOReader. Open source is awesome!
Support the Project ❤️
If you found this project helpful, you can support the work through my GitHub Sponsor page.
License: GPLv3
more like this
Prismedia
Your whole media life in one private, self-hosted library—watch, read, listen, request, and manage across web, iPhone,…
Translation-Gummy
Translation Gummy is a magical gadget which enables user to be able to speak and understand other languages.
