-
Notifications
You must be signed in to change notification settings - Fork 16
6. AI Providers & Models
The plugin gives you a few options for the AI backend. You can swap between them based on what works best for you.
This is the default and generally the best choice for most people:
- It has a generous free tier that is more than enough for regular reading.
- Models like
gemini-3.6-flash(default primary) andgemini-3.5-flash-lite(default secondary) are extremely fast and capable. - Other supported models include
gemini-3.5-flash,gemini-3.1-flash-lite,gemini-2.5-flash,gemini-2.5-flash-lite(free), andgemini-2.5-pro(paid). - It can handle a huge amount of context at once, which is great for long books.
- Reasoning: Gemini 2.5+ models support internal reasoning levels.
If you already use the OpenAI API, you can plug in your key here:
- You can use high-performance models like
gpt-5.6-terra,gpt-5.6-luna,gpt-5.5,gpt-5.4-mini, andgpt-5.4-nano. - Note:
gpt-4oandgpt-4o-miniare now considered legacy/deprecated and are available via the "Custom Model" option. - Just keep in mind that you need an API key with actual prepaid credits—a standard ChatGPT Plus subscription doesn't cover API usage.
DeepSeek offers powerful open-weight reasoning models that are very cost-effective:
- Use
deepseek-v4-flashfor standard fast requests, ordeepseek-v4-profor complex extraction. - You must create an API key at DeepSeek's platform.
Claude models are excellent for literary analysis and complex character extraction:
-
Claude 5 Sonnet (
claude-sonnet-5), Claude 4.6 Sonnet (claude-sonnet-4-6), and Claude 4.5 Haiku (claude-haiku-4-5) are the current supported versions. - Claude natively supports structured JSON outputs and sophisticated extended thinking.
For advanced users, you can configure up to two custom API providers (e.g., OpenRouter, openmodel.ai, LiteLLM, or self-hosted models) supporting either OpenAI or Anthropic payload formats.
-
Configurable Base URL: Set your own endpoint (e.g.,
https://openrouter.ai/api/v1/chat/completionsorhttps://api.openmodel.ai/v1/messages). -
Auto-Format Detection: The plugin automatically detects Anthropic-compatible endpoints (if the URL contains
/v1/messagesor/messages) and formats the request body and headers accordingly. You can also explicitly specify the format in the config file. - Model Selection: Manually specify any model ID supported by your provider.
- Is Reasoning Model: Toggle this if your custom model is a reasoning model (e.g., DeepSeek-R1) to allocate a larger token budget for extended thinking chains.
-
Provider-Specific Headers: Automatically includes required attribution headers (like
HTTP-RefererandX-Title) for OpenRouter, and required version/authorization headers for Anthropic-compatible endpoints.
For supported reasoning models, you can configure the "Reasoning Effort" in AI Settings to control internal 'thinking' time.
- Unset: No specific instruction sent; the model uses its internal defaults.
- Low: Fast, economical extraction for simple books.
- Medium: Balanced depth for most standard narratives.
- High: Detailed analysis for complex character webs.
Applies to: GPT-5.x (o1/o3/gpt-5), Claude (sonnet/opus/haiku), and Gemini 2.5+.
Note: DeepSeek V4 reasons inherently — this setting has no effect on it.
Sometimes API requests fail, usually because of rate limits or temporary network issues. To handle this, the plugin lets you set a primary and secondary model.
If your primary model (like claude-sonnet-5) fails, it'll automatically try the secondary model (like gemini-3.5-flash-lite) before giving up.
You can manage your API keys for all providers in one place! Go to Tools Menu → X-Ray → Settings → AI Settings → API Keys & Providers.
Avoid typing complex API keys on your e-reader keyboard by setting them up in seconds from your smartphone or laptop:
-
🌐 Cloud Relay (Recommended):
- Generates a QR code and short pairing code on your e-reader.
- Scan the QR code or visit
https://xray-setup.ultimatejimmy.workers.dev/in any browser. - End-to-end encrypted with zero-knowledge AES-256-GCM browser encryption.
-
📶 Local Wi-Fi (Offline LAN):
- Hosts a local web portal on your home Wi-Fi (
http://<ereader-ip>:8088). - Supported on Android, Kobo, PocketBook, and Desktop platforms. Automatically hidden on Kindle devices due to Kindle OS firewall restrictions.
- Hosts a local web portal on your home Wi-Fi (
The menu allows you to choose between:
-
Config Key: Reading directly from your
xray_config.luafile. - UI Key: A key entered directly in the KOReader interface (overrides the config file).
- Web / Phone Key: Transmitted seamlessly via QR setup.
This allows for easy switching between different keys or testing new providers without editing files manually.
If you ever see a 429 Quota Exceeded error, it just means you've hit your provider's rate limit. Wait a minute or two and try again. If you're using Gemini's free tier, you should easily be able to process a few books a day without hitting hard caps.
For more information on the config file, see Advanced Usage.