ollama-logseq is a Logseq plugin that connects your graph to any OpenAI-compatible chat completion endpoint.
It is designed for local and hosted LLM workflows alike:
- OpenAI
- Ollama
- LM Studio
- vLLM
- LocalAI
- any other provider that exposes an OpenAI-compatible
/chat/completionsAPI
The plugin gives Logseq users a command palette for AI actions, block and page aware prompts, streamed responses inserted directly into the graph, flashcard generation, and a customizable command system that can be extended per graph.
The plugin adds an AI command layer on top of Logseq blocks and pages.
From Logseq, you can:
- open an AI command palette from a shortcut, slash command, or toolbar button
- run prompts against the current block or the entire page
- summarize content into structured Logseq blocks
- generate nested TODO breakdowns from a task block
- turn notes into flashcards
- define your own prompt commands in your graph
- override bundled commands without changing plugin source code
- pin a specific model to a specific custom command
Responses are streamed into Logseq as they arrive. When possible, the plugin converts markdown-like output into proper nested Logseq blocks instead of leaving everything in one long paragraph.
- Works with any OpenAI-compatible chat completion endpoint
- API key is optional for local endpoints that do not require authentication
- Supports multiple configured models
- Per-command model override support
- Streamed response rendering while the model is generating
- Block-aware and page-aware commands
- Structured output insertion into nested Logseq blocks
- Flashcard generation with
#card - Graph-level custom commands and command overrides
- Keyboard shortcut to reload command templates without restarting the plugin
- Context menu commands for no-input block/page commands that explicitly use page or block context
After the plugin is enabled, users can access it in several ways:
- toolbar button with a wand icon
- slash command
/ai - slash command
/llm - configurable shortcut to open the AI command palette
- configurable shortcut to reload commands
- block context menu entries for eligible commands
The command palette groups commands into:
Block CommandsPage Commands
If a command requires user input, selecting it opens a prompt box. If it does not require input, it runs immediately.
Use your preferred Logseq plugin installation workflow.
If you are installing from source:
- Clone this repository.
- Install dependencies with
pnpm install. - Build the plugin with
pnpm build. - Load the project as an unpacked plugin in Logseq.
This project is configured as a Logseq plugin package and points Logseq to the built frontend entry at dist/index.html.
The plugin exposes the following settings in Logseq.
| Setting | Purpose | Notes |
|---|---|---|
Base API URL |
Base URL for the OpenAI-compatible API | You can enter either the API base, such as https://api.openai.com/v1, or the full .../chat/completions URL |
API token |
Bearer token used for requests | Leave empty for local endpoints that do not require auth |
Models |
List of model names, one per line | The first model becomes the default fallback model |
Shortcut |
Opens the plugin command palette | Default: mod+shift+o |
Reload commands shortcut |
Reloads command templates | Default: mod+shift+u |
Command templates file |
Page name inside the current graph that contains custom command definitions | Matching titles override bundled commands, empty user prompts remove bundled commands, new titles append new commands |
The plugin ships with a set of bundled commands in public/defaultCommands.md.
- asks the model whatever the user types
- requires manual input
- no page or block context is injected automatically
- requires manual input
- injects the current page content into the prompt
- useful for page-wide Q and A, analysis, or transformation
- requires manual input
- injects the current block tree into the prompt
- useful for rewriting, clarifying, or expanding a selected block and its children
- no manual input required
- uses the current page as context
- inserts a structured summary under a
Summaryroot block - typically writes near the end of the current page
- no manual input required
- uses the current block tree as context
- inserts a structured summary under a
Summaryroot block below the current block
- no manual input required
- uses the current block tree as the task input
- asks the model for a nested breakdown
- inserts nested
TODOblocks in Logseq
- no manual input required
- uses the current block tree as the knowledge source
- generates:
- a question block tagged with
#card - an answer block directly below it
- a question block tagged with
For block-aware commands, the plugin reads the current block and its child tree, not only the single visible line.
That means a command can operate on:
- a single block
- a block with nested bullets beneath it
- a small outline subtree
For page-aware commands, the plugin reads the full page block tree.
This is useful for:
- page summaries
- page-level study guides
- extracting action items from a page
- page-wide rewriting or analysis prompts
For standard commands, the plugin tries to transform LLM output into Logseq-friendly nested blocks.
Examples:
- headings are preserved as blocks
- lists become nested list blocks
- markdown checkboxes become
TODO - code blocks are preserved as block text
This makes outputs much more usable inside a graph than a raw wall of text.
Flashcard commands use a two-step flow:
- generate a question
- generate a short answer based on that question and the original source content
The resulting question block is tagged with #card, which fits standard Logseq flashcard workflows.
One of the most useful parts of this plugin is that commands are data-driven.
You can create your own commands in a page inside your graph, point the Command templates file setting at that page, and reload commands without restarting Logseq.
The command template source is read from a page in the current graph.
Recommended workflow:
- Create a page such as
AI Commands. - Paste your command definitions into that page.
- Set
Command templates filetoAI Commands. - Press the reload shortcut, or restart the plugin.
If the page cannot be loaded, the plugin falls back to the bundled defaults and shows a warning.
Custom commands do not replace the whole bundled set by default.
Instead, the plugin merges commands using the command title:
- if a custom command title matches a bundled command title, the custom command overrides it
- if a custom command title is new, it is appended as an additional command
- if a matching custom command has an empty
llm-user, it removes the bundled command
Title matching is case-insensitive.
The reload shortcut re-reads:
- bundled commands
- your graph command page
This is useful when you are iterating on prompts.
Note that Logseq does not provide a way to unregister stale block context menu entries. If you remove a command that previously appeared in the context menu, an old menu item may remain visible until the plugin is restarted. The plugin updates active command mappings on reload, but it cannot fully remove stale menu entries on its own.
Commands are written as markdown list items.
At minimum, a command starts with:
- llm-command My CommandSupported sections are:
llm-systemllm-userllm-follow-up-userllm-responsellm-outputllm-model
- llm-command Rewrite block as bullets
- llm-system
```md
You rewrite notes into concise bullet points.
```
- llm-user
```md
Rewrite the following into short actionable bullets:
${block}
```- llm-command Extract page action items
- llm-system
```md
You extract actionable tasks from notes and return only concise task items.
```
- llm-user
```md
Review the following page and extract action items:
${page}
```
- llm-response
```md
Action Items
${response}
```- llm-command Make vocabulary card
- llm-system
```md
You create compact study flashcards.
```
- llm-output flashcard
- llm-user
```md
Create a question for a flashcard. Provide the question only. Here is the knowledge to check:
${block}
```
- llm-follow-up-user
```md
Given the question ${question} and the context of ${block}, what is the answer? Be brief and provide the answer only.
```If you want to replace the built-in Summarize Block command with your own version, define a command with the same title:
- llm-command Summarize Block
- llm-system
```md
You summarize technical notes into crisp study bullets.
```
- llm-user
```md
Summarize the following block tree into key insights, open questions, and next steps:
${block}
```
- llm-response
```md
Summary
${response}
```To remove a bundled command, define it with the same title but leave llm-user empty:
- llm-command Command NameThe plugin replaces variables inside command templates before sending requests.
These are available in llm-system, llm-user, and where applicable llm-follow-up-user:
| Variable | Meaning |
|---|---|
${input} |
User-entered text from the prompt dialog |
${block} |
Current block tree content |
${page} |
Current page content |
${pageName} |
Current page name when page context is resolved |
${question} |
Generated flashcard question, only in follow-up flashcard prompts |
These are available in llm-response:
| Variable | Meaning |
|---|---|
${response} |
The model output |
${input} |
Original user input, if any |
${block} |
Current block tree content, if used |
${page} |
Current page content, if used |
${pageName} |
Current page name, if used |
- if a command uses
${input}, the plugin opens the prompt UI before execution - if a command uses
${page}, it is treated as a page command - if a command does not use
${input}, it runs immediately when selected - if
llm-modelis omitted, the first configured model from settings is used llm-outputdefaults tostructuredllm-output flashcardrequiresllm-follow-up-user
The plugin supports two model selection levels:
Set one model per line in the Models setting. The first entry is used as the default fallback.
Use llm-model in a command template to pin a command to a specific model:
- llm-command Deep reasoning review
- llm-model gpt-4.1
- llm-user
```md
Review the following and identify hidden assumptions:
${block}
```This is useful when you want:
- a fast cheap model for simple rewrites
- a stronger reasoning model for planning or critique
- a local model for private notes
- a hosted model for higher quality summaries
- Keep at least one valid model in the
Modelssetting. - Start with simple custom commands before building multi-step prompts.
- Use
${block}when you want to operate on a focused subtree. - Use
${page}only when you really need whole-page context. - Prefer short, explicit system prompts.
- Use
llm-responsewhen you want inserted output to have a stable heading such asSummaryorAction Items. - Reload commands after editing your command page.
- Restart the plugin if you removed a context-menu-visible command and the stale menu entry is still shown.
- Give commands clear, action-oriented titles.
- Make the user prompt explicit about output format.
- Ask for note-friendly structure when the result should become Logseq blocks.
- Use flashcard output only for true question/answer workflows.
- If a command should be reusable from the block context menu, avoid
${input}and include${block}or${page}explicitly. - Keep custom command definitions on a dedicated page so they are easy to maintain.
Check:
- Base API URL
- API token
- model name
- whether your server really supports OpenAI-compatible chat completions
Check:
- that
Command templates filepoints to an existing page in the current graph - that your command syntax starts with
- llm-command ... - that you pressed the reload shortcut or restarted the plugin
The prompt UI only opens if the command template contains ${input}.
Only commands that:
- do not require manual input
- explicitly reference
${block}or${page}
are registered as block context menu actions.
MIT