Skip to content

captainflasmr/ollama-buddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,035 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ollama Buddy: Local LLM Integration for Emacs

img/ollama-buddy-logo.svg

Ollama Buddy

An Emacs package for interacting with local LLMs via Ollama, with support for remote providers (OpenAI, Claude, Gemini, Grok, Copilot, Codestral, DeepSeek, OpenRouter, OpenCode Go) and Ollama Cloud models. Requires Emacs 29.1+.

(use-package ollama-buddy
  :ensure t
  :bind
  ("C-c o" . ollama-buddy-role-transient-menu)
  ("C-c O" . ollama-buddy-transient-menu))

That’s it!, start ollama serve, open Emacs, press C-c o, select [o] to open chat, and go, here is what will be presented:

img/ollama-buddy-welcome.jpg

There are videos demonstrating functionality:

https://www.youtube.com/@OllamaBuddyforEmacs

Want More Details?

For a deeper dive have a ganders at:

  • Full README – Detailed README tutorials, transient menu guide, and role setup

Demos

See - Videos

In-buffer replacement demo

Demonstrating in-buffer in-line modification, now we are out of the chat buffer!

img/ollama-buddy-screen-recording_037.gif

Tool Calling Demo

LLMs can invoke Emacs functions: read/write files, execute shell commands, search buffers, and more.

img/ollama-buddy-screen-recording_034.gif

Advanced Tool Calling Demo

Demonstrating advanced ollama tool calling with multiple tools working together.

img/ollama-buddy-screen-recording_035.gif

Quick Demo

Submit queries, swap models, view token usage and statistics:

img/ollama-buddy-screen-recording_011.gif

Features

  • Plan Mode – Structured task planning with org-mode TODO integration. /plan generates a step-by-step plan as TODO headings; cycle states with S-<right>; execute steps with /plan-next (with full tool calling support)
  • Tool Calling – LLMs can invoke registered Emacs functions (file ops, shell commands, buffer search, calculations). Safe mode restricts to read-only tools; unguarded mode () bypasses all prompts for uninterrupted execution.
  • Multiple Providers – Local Ollama, Ollama Cloud, OpenAI, Claude, Gemini, Grok, GitHub Copilot, Codestral, DeepSeek, OpenRouter, OpenCode Go, and any generic OpenAI-compatible server (LM Studio, llama.cpp, vLLM, Jan…)
  • Web Search – Inline @search(query) syntax for real-time web search via Ollama’s API
  • Interactive Menus – Transient popup menus with role-based command grouping
  • Roles & Presets – Switchable command configurations (developer, writer, tutor, documenter, custom); each command carries a :destination hint (chat or in-buffer) so rewrites go to the right place automatically
  • Sessions & History – Save/load conversations, prompt history navigation
  • Thinking Block Folding – Reasoning model output (<think> tags, DeepSeek API) rendered as collapsible org headings; TAB on the heading to peek mid-stream
  • File Attachments – Attach files and images (vision models) to conversations
  • Model Management – Pull, delete, copy models; categorized recommendations; cloud model support
  • Multishot & Benchmark – Send the same prompt to multiple models simultaneously; benchmark all models in one command with per-model timeout
  • Parameters – Full control over temperature, top_k, top_p, and all Ollama API options
  • Token Tracking – Real-time token usage statistics with graphs
  • Skills – Specialized AI personas and task-specific instructions integrated into the User Prompts library; use `/skill` slash command or `@skill(name)` for inline expansion
  • RAG – Index local documents and source code; retrieve relevant context via semantic search; inline @rag(query) syntax; configurable embedding backend (Ollama /api/embed or any OpenAI-compatible /v1/embeddings service, e.g. LM Studio)
  • In-Buffer Replace – Stream LLM output directly into the source buffer, replacing the selected region in-place; accept/reject confirmation; inline diff view (C-c d) with word-level smerge highlighting; automatic code-fence stripping

Alternative LLM Feature Comparison Matrix

A cross-cutting view of key features across the major chat clients, to the best of my knowledge, I will try and keep up-to-date, but things are moving quickly!

Featuregptelchatgpt-shellellamaorg-aiollama-buddy
Zero-config OllamaNoNoNoNoYes
Works in any bufferYesYesYesYesYes
Dedicated chat bufferYesYesYesYesYes
Org-mode native outputYesYesYesYesYes
StreamingYesYesYesYesYes
Vision / image inputYesYesYesNoYes
Thinking block supportYesYesYesNoYes
Tool callingYesYesYesNoYes
MCP supportYesNoYesNoNo
RAG / document indexingNoNoYesNoYes
Web search integrationNoNoNoNoYes
In-buffer replace / rewriteYesNoYesNoYes
Inline code completionNoNoNoNoYes
Session save/loadYesYesYesYesYes
Transient menuYesNoYesNoYes
Prompt historyNoYesNoNoYes
Multi-model comparisonNoNoNoNoYes
Slash commandsNoNoNoNoYes
Image generationNoYesNoYesNo
Speech input/outputNoNoNoYesNo
Project integrationNoNoNoNoYes
Ollama Cloud modelsNoNoNoNoYes
Curl backend fallbackNoNoNoNoYes
MELPAYesYesYesYesYes
Emacs requirement27.128.128.127.129.1

Updates

What’s New (v7.4.2)

Kimi K2.6 cloud model support.

  • Kimi K2.6 Cloud Model – Added kimi-k2.6:cloud to ollama-buddy-cloud-models (appears in C-c m with the indicator). Moonshot AI’s native multimodal agentic model, running on Ollama’s cloud (NVIDIA Blackwell hardware) with long-horizon coding, coding-driven design, autonomous execution, and swarm orchestration capabilities. Requires a paid Ollama cloud subscription (https://ollama.com/upgrade) – without one, prompts return an authentication error pointing to the upgrade page. Most other entries in ollama-buddy-cloud-models still run on the free tier.

What’s New (v7.4.1)

Response post-processing hook and a thinking-block point-anchor fix.

  • =ollama-buddy-response-post-process-functions= – New hook run on the streamed response region just before markdown-to-org conversion. Each function is called with (START END) buffer positions and may edit the region freely.
  • =ollama-buddy–normalize-numbered-lists= – Default hook entry that splits glued numbered-list items of the form N. [CATEGORY] ... onto their own lines when dense models (notably cloud gemma) emit them as a single paragraph. Idempotent on already-clean input.
  • Thinking-block point anchor fix – Fixed the first response token being inserted at the top of the folded thinking block instead of after *** Response. Both the API-style (message.thinking) and tag-style (</think>) paths now re-anchor to (point-max) after finalize-thinking-block returns.
  • Emacs Blog Reviewer prompt – New user prompt that reviews an Emacs blog post for grammar and technical accuracy (function/variable names, key bindings, elisp syntax, deprecated APIs, version claims). One-line-per-issue output format.

What’s New (v7.4.0)

Directory-scale project annotation via structured output.

  • =/annotate-dir= – Batch-annotate every source file in a directory. Each file is attached, sent as its own request, and the returned JSON is auto-applied to .simply-annotations.el when the response finishes. Prefix arg recurses. Cancel with /annotate-cancel.
  • Context-aware batching – Estimated token cost (chars / 4) is checked against the current model’s context window; oversized files are skipped. Configurable via ollama-buddy-annotate-context-reserve (default 0.5).
  • Structured-output skill auto-load – The batch installs the Annotate Project skill and its #+FORMAT: JSON schema before starting, so structured output is guaranteed. The schema now allows file, defun, and line tags.
  • =C-c A= – New chat-buffer binding for ollama-buddy-annotate-apply-last-response.
  • New cloud models – Added deepseek-v3.2:cloud, gemini-3-flash-preview:cloud, qwen3-next:80b-cloud, and nemotron-3-super:cloud.

What’s New (v7.3.0)

Direct launch support for external agents.

  • Direct Agent Launch – The /launch system now supports external tools that are not built-in ollama launch integrations. Registry entries with :direct t are invoked as standalone executables in a terminal, bypassing ollama launch entirely. Direct agents only require their own executable on PATH (no ollama dependency).
  • Oh My Pi (omp) – Added to the built-in agent registry as the first direct agent.
  • Flexible Model Passing – Direct agents receive --model MODEL by default. The :model-flag property lets entries customise or disable model passing.
  • Detached Terminal Sessions – Launched terminals are fully decoupled from Emacs; closing Emacs no longer kills running agent sessions.
  • Standalone LaunchM-x ollama-buddy-launch-external (or transient v) launches an agent from the current directory without requiring the chat buffer. In Dired, opens in the displayed directory.

What’s New (v7.2.0)

Small model warning for agent launch.

  • Small Model Launch Warning – When launching a local model below 7B parameters via /launch or the Model Management Launch button, a confirmation warning now explains that coding agents prepend 20,000+ tokens of system prompt to every request, which can cause small models to appear frozen or take many minutes to respond. Configurable via ollama-buddy-launch-small-model-threshold (default 7; set to nil to disable). Cloud models skip the warning.

What’s New (v7.1.4)

Expanded launch agent registry.

  • Full =ollama launch= Agent Registry – The built-in agent registry now includes all frontends supported by ollama launch: Cline, Droid, OpenCode, OpenClaw, and Pi, in addition to Claude Code and Codex. Each agent only appears when its executable is found on PATH.

What’s New (v7.1.3)

Fix process-filter crash on cloud usage limit responses.

  • Cloud limit crash fix – Sending a prompt to an Ollama cloud model when the session was at 100% used to spam error in process filter: Wrong type argument: listp, 82 and never surface a real message. The non-2xx response body’s chunked-transfer chunk-size prefix (e.g. 82\r\n{...}) was being parsed as an integer and crashing alist-get downstream. The streaming filter now strips leading non-={= bytes before parsing and requires the parsed value to be a cons; handle-http-error is also defensive against non-alist input. Cloud usage limits now produce a clean error in the chat buffer.

What’s New (v7.1.2)

GLM 5.1 cloud model support.

  • GLM 5.1 Cloud Model – Added glm-5.1:cloud to ollama-buddy-cloud-models (appears in C-c m with the indicator). GLM-5.1 is Z.ai’s next-generation flagship model for agentic engineering, with significantly stronger coding capabilities and support for tools and thinking.

What’s New (v7.1.1)

Gemma 4 model support.

  • Gemma 4 Cloud Model – Added gemma4:31b-cloud to ollama-buddy-cloud-models (appears in C-c m with the indicator).
  • Gemma 4 Recommended Models – Added gemma4:e2b, gemma4:e4b, gemma4:latest and gemma4:26b to the “Efficient & Capable” category shown via C-c L. gemma4:26b is a Mixture-of-Experts model with only 4B active parameters, so it runs comfortably on 16GB GPUs (with partial CPU offload) and on Apple Silicon with shared memory. The dense gemma4:31b is still left off the recommended list.
  • Gemma 4 Vision Support – All Gemma 4 variants are registered as vision models, so the indicator lights up and image attachment works with them.

What’s New (v7.1.0)

Thinking toggle and Ollama offline detection.

  • Thinking Toggle/think slash command (or transient T) controls whether reasoning models emit a thinking block. When disabled, models skip reasoning for faster, cheaper responses. Header shows (enabled) or (disabled).

What’s New (v7.0.0)

Plan mode — structured task planning with org-mode TODO integration.

  • Plan Mode/plan activates a planning workflow where the LLM generates structured plans as org-mode TODO headings. Cycle states with S-<right> (TODODOINGDONE | SKIP). Execute steps with /plan-next (one at a time, with full tool calling) or /plan-all (all remaining). /plan-done marks a step complete; /plan-status shows progress; /plan-stop deactivates.
  • Tool Calling Progress – Status line and echo area now show live feedback: ⚒ Preparing write_file… during streaming, ⚒ Running write_file… during execution, ⚒ Tools complete when finished.
  • Enhanced =write_file= Tool – Reports file size and line count in both the echo area and tool results.

What’s New (v6.0.0)

Launch external frontends and comprehensive code quality improvements.

  • =/launch= Slash Command – Launch any Ollama model in an external terminal with a frontend tool (e.g. Claude Code). Runs ollama launch claude --model MODEL with auto-detected terminal emulator. Detects via $TERMINAL, $TERM_PROGRAM, xdg-terminal-exec, or PATH scan.
  • Launch in Model Management – Each model in C-c M now has a Launch button when frontends are detected.
  • Welcome Screen Indicator – Shows ⚡ launch: claude (via kitty) when launch frontends are available on PATH.
  • Code Quality – Fixed process/buffer leaks, added vectorp guards for API responses, replaced busy-waits, consolidated duplicate code, improved error handling across the package.

What’s New (v5.1.0)

Unguarded tool mode and MiniMax-M2.7 cloud model.

  • Unguarded Mode/unguarded slash command (or transient G) bypasses ALL safety prompts, letting tools run to completion without interruption. No confirmation for unsafe tools, no large-result warnings, safe-mode overridden. Header line turns red and shows as a clear visual warning.
  • MiniMax-M2.7 Cloud Model – Added minimax-m2.7:cloud to ollama-buddy-cloud-models.

What’s New (v5.0.1)

Auto-scroll toggle for following streaming output.

  • Auto-Scroll ToggleC-c g toggles ollama-buddy-auto-scroll, jumping to the end of the buffer when enabled. Header line shows when active. Works when toggled mid-stream.

What’s New (v5.0.0)

Tool calling for all providers — OpenAI, Claude, and Gemini API types all support function calling through ollama-buddy-provider-create.

  • Tool Calling for External Providers – All three API types (OpenAI-compatible, Claude, Gemini) now support tool calling. Tools are automatically converted from the internal format to each provider’s native schema at send time. This covers OpenAI, DeepSeek, Grok, OpenRouter, Copilot, Codestral, LM Studio, Anthropic Claude, and Google Gemini.

What’s New (v4.2.0)

Tool-augmented search — LLMs can now autonomously search the web and query local documents during tool calling.

  • =web_search= Tool – Models can autonomously search the web for current information during tool calling conversations. Uses the Ollama web search API; returns plain-text results (titles, URLs, snippets) directly as tool context.
  • =rag_search= Tool – Models can autonomously search local RAG indexes for relevant document chunks during tool calling. Searches all indexes by default, or a specific one by name.
  • Emacs 29.1 Minimum – Org folding now uses the org-fold text-property API directly, fixing thinking block folding issues on modern Emacs.
  • Thinking Fold RobustnessTAB to peek at a thinking block mid-stream now stays open instead of being immediately re-folded.
  • Welcome Screen – Extra commands under a folded ** More Commands heading; project path is a clickable dired link.
  • Model Management – Running models listed individually with per-model Unload buttons; [x]/[ ] checkbox removed.
  • =C-c E= – Toggle tool auto-execute from the chat buffer.

Recent Changes

VersionSummary
7.6.0Dynamic cloud model discovery — ollama-buddy-cloud-models auto-fetched from ollama.com/api/tags; /sync force-refresh; ? opens transient.
7.5.0OpenCode Go subscription integration — single n: prefix exposes all 14 models with one shared API key; ollama-buddy-provider-create now accepts function forms for :api-type / :endpoint for per-model dispatch.
7.4.1Response post-processing hook (ollama-buddy-response-post-process-functions) with numbered-list normaliser for dense cloud models; thinking-block point-anchor fix; Emacs Blog Reviewer user prompt.
7.4.0Directory-scale project annotation — /annotate-dir batches source files through a structured-output schema, auto-applies thread-shaped annotations to .simply-annotations.el, context-aware, project-relative keys.
7.3.0Direct agent launch — external tools invoked as standalone executables; standalone launch from transient/dired; detached terminal sessions; Oh My Pi (omp) as first direct agent.
7.2.0Small model launch warning — agents prepend 20K+ tokens of system prompt; models below 7B now trigger a confirmation warning explaining potential performance impact.
7.1.4Expanded ollama launch agent registry — Cline, Droid, OpenCode, OpenClaw, Pi now detected alongside Claude Code and Codex.
7.1.0Thinking toggle (/think, ✦=/=✧ indicator) — control reasoning output; Ollama offline detection with clear messages.
7.0.0Plan mode — structured task planning with org-mode TODO integration; tool calling progress feedback; enhanced write_file tool output.
6.0.0/launch slash command — launch models in external terminals with frontends (e.g. Claude Code); auto-detects terminal; Launch button in Model Management; comprehensive code quality fixes.
5.1.0Unguarded tool mode ( indicator, red header line) — bypass all safety prompts; MiniMax-M2.7 cloud model.
5.0.1Auto-scroll toggle (C-c g, indicator); works mid-stream.
5.0.0Tool calling for all providers: OpenAI, Claude, and Gemini API types support function calling; HTTP error detection; Gemini native systemInstruction.
4.2.0Tool-augmented search: web_search and rag_search built-in tools; Emacs 29.1 minimum; thinking fold robustness; welcome screen folded commands; model management running models section.
4.1.1Recommended Models browser (C-c L), model letter ordering matches display, session load moved to C-c f.
4.1.0Response property drawers (:TOKENS:, :RATE:, etc.), org file links for attachments, SVG context bar, removed token stats toggle.
4.0.0Generic provider system (ollama-buddy-provider-create) — register any OpenAI/Claude/Gemini-compatible API with one call. Existing require wrappers still work but are deprecated.
3.7.1Code quality, async model info, error cleanup, /cd directory switching, removed Fabric/Awesome.
3.7.0RAG pause/resume with periodic checkpointing; new built-in tools (search_files, get_region, get_buffer_info, describe_symbol, eval_elisp).
3.6.0RAG incremental updates (re-index only changed files) and cancellation support.
3.5.1Curl backend refactor — unified request pipeline, shared stream processor, full feature parity with network-process backend (46% code reduction).
3.5.0Project Init (experimental) — /init generates a cached project summary that auto-loads in future sessions; a step towards code-oriented LLM workflows.
3.4.1Thinking Peek and Rewind — TAB peek at thinking mid-stream; C-u C-u C-c C-c to rewind conversation from any prompt heading.
3.4.0Skills — Local Org-mode based AI personas and task-specific instructions; `/skill` slash command and `@skill(name)` inline syntax.
3.3.0Smart Project Integration — `project.el` support for contextual file attachment and `/project` slash command.
3.2.2Main transient menu reorganization (C-c O) — 4x2 compact grid with streamlined sub-menus and top-level History/Sessions.
3.2.1Benchmark all models (C-c u) — one-command multishot across all models with per-model timeout; builds persistent token stats.
3.1.0Inline ghost-text code completions (ollama-buddy-completion) — simple, manual Copilot-style completions with FIM context, thinking model support, fence stripping.
3.0.0Generic OpenAI-compatible chat provider (ollama-buddy-openai-compat) — connect to LM Studio, llama.cpp, vLLM, Jan, or any OpenAI-API server.
2.9.2:destination property for command definitions — per-command routing to chat or in-buffer, overriding the global toggle; all built-in commands and presets pre-annotated.
2.9.1Welcome screen tips — ollama-buddy-tips.el shows a random usage tip on every fresh chat buffer; disable with (setq ollama-buddy-show-tips nil).
2.9Configurable RAG embedding backend — ollama-buddy-rag-embedding-base-url and ollama-buddy-rag-embedding-api-style let you point RAG at any /v1/embeddings server (e.g. LM Studio) instead of Ollama’s /api/embed.
2.8.1In-buffer replace polish: inline diff view (C-c d, word-level smerge highlighting), automatic clean-output tone, code-fence stripping, C-c W toggle.
2.8.0Initial in-buffer replace mode — stream rewrites directly into the source buffer; C-c C-c accept / C-c C-k reject.

See CHANGELOG.org for full history.

Installation

MELPA Simple

(use-package ollama-buddy
  :ensure t
  :bind
  ("C-c o" . ollama-buddy-role-transient-menu)
  ("C-c O" . ollama-buddy-transient-menu))

On first launch, press C-c OI to install the bundled presets and user prompts for the full experience (see Installing Presets and User Prompts).

With Remote Providers (v4.0+ recommended)

(use-package ollama-buddy
  :ensure t
  :bind
  ("C-c o" . ollama-buddy-role-transient-menu)
  ("C-c O" . ollama-buddy-transient-menu)
  :config
  (require 'ollama-buddy-provider)
  (ollama-buddy-provider-create
   :name "OpenAI"
   :prefix "a:"
   :api-key (lambda () (auth-source-pick-first-password :host "ollama-buddy-openai" :user "apikey"))
   :endpoint "https://api.openai.com/v1/chat/completions"
   :default-model "gpt-4o"
   :models-endpoint "https://api.openai.com/v1/models"
   :models-filter (lambda (id) (string-match-p "gpt" id)))
  ;; add other providers similarly …
  )

With Remote Providers (legacy, still works)

(use-package ollama-buddy
  :ensure t
  :bind
  ("C-c o" . ollama-buddy-role-transient-menu)
  ("C-c O" . ollama-buddy-transient-menu)
  :custom
  (ollama-buddy-openai-api-key
   (auth-source-pick-first-password :host "ollama-buddy-openai" :user "apikey"))
  ;; add other providers similarly …
  :config
  (require 'ollama-buddy-openai nil t)
  ;; other cloud providers …
  )

With a Local OpenAI-Compatible Server (LM Studio, llama.cpp, vLLM…)

No API key needed for local servers. Use ollama-buddy-provider-create with :models-endpoint to auto-discover models:

(use-package ollama-buddy
  :ensure t
  :bind
  ("C-c o" . ollama-buddy-role-transient-menu)
  ("C-c O" . ollama-buddy-transient-menu)
  :config
  (require 'ollama-buddy-provider)
  (ollama-buddy-provider-create
   :name "LM Studio"
   :prefix "l:"
   :endpoint "http://localhost:1234/v1/chat/completions"
   :models-endpoint "http://localhost:1234/v1/models"))

Optionally also route RAG embeddings through the same server:

(setq ollama-buddy-rag-embedding-base-url "http://localhost:1234")
(setq ollama-buddy-rag-embedding-api-style 'openai)
(setq ollama-buddy-rag-embedding-model "nomic-embed-text")

Manual

git clone https://github.com/captainflasmr/ollama-buddy.git
(add-to-list 'load-path "path/to/ollama-buddy")
(require 'ollama-buddy)
(global-set-key (kbd "C-c o") #'ollama-buddy-role-transient-menu)
(global-set-key (kbd "C-c O") #'ollama-buddy-transient-menu)

Installing Presets and User Prompts

Role presets and user prompts ship with the package but need to be copied into your Emacs configuration directory to be editable. If they are missing, the chat welcome screen will show a reminder and the transient menu will offer an Install Extras entry.

From Emacs (recommended)

Press C-c OI (or M-x ollama-buddy-install-extras). This copies the bundled directories from the installed package, or downloads them from GitHub if the package was installed without them.

Manual (shell)

cd ~/.emacs.d

# extract out the ollama-buddy-presets and ollama-buddy-user-prompts
curl -sL https://api.github.com/repos/captainflasmr/ollama-buddy/tarball/main | \
    tar -xzf - --transform=’s|[^/]*/||’ \
        --wildcards \
        ‘*/ollama-buddy-presets/*’ \
        ‘*/ollama-buddy-user-prompts/*

The two directories installed are:

  1. =ollama-buddy-presets= – Pre-defined role presets (developer, writer, tutor, etc.) as .el files.
  2. =ollama-buddy-user-prompts= – Bundled system prompts organized by category (coding, writing, emacs, skills, etc.).

Exporting Skills for AI Agent Tools

User prompts can be exported as named skills for Claude Code, opencode, and other compatible agent tools. Each skill becomes a directory under ~/.claude/skills/ with a SKILL.md file containing YAML frontmatter, description, trigger phrases, and the prompt body as markdown.

  • M-x ollama-buddy-user-prompts-export-skills – Export all prompts as skills (with confirmation). With C-u prefix, prompts for custom directories.
  • M-x ollama-buddy-user-prompts-export-skill – Export a single prompt selected via completion.

Configure targets:

;; Primary target (default ~/.claude/skills/)
(setq ollama-buddy-skills-export-directory "~/.claude/skills/")

;; Optional secondary target (e.g. project-local .agents/skills/)
(setq ollama-buddy-skills-export-agents-directory
      (expand-file-name ".agents/skills/" (project-root (project-current t))))

My current configuration

(use-package ollama-buddy
  :demand t
  :bind
  ("C-c o" . ollama-buddy-role-transient-menu)
  ("C-c O" . ollama-buddy-transient-menu)
  :config
  ;; overall default model
  (setq ollama-buddy-default-model "glm-4.7:cloud")

  ;; ;; deprecated external LLM
  ;; (setq ollama-buddy-openai-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-openai" :user "apikey"))
  ;; (setq ollama-buddy-claude-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-claude" :user "apikey"))
  ;; (setq ollama-buddy-gemini-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-gemini" :user "apikey"))
  ;; (setq ollama-buddy-grok-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-grok" :user "apikey"))
  ;; (setq ollama-buddy-codestral-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-codestral" :user "apikey"))
  ;; (setq ollama-buddy-openrouter-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-openrouter" :user "apikey"))
  ;; (setq ollama-buddy-deepseek-api-key
  ;;       (auth-source-pick-first-password :host "ollama-buddy-deepseek" :user "apikey"))
  ;; (require 'ollama-buddy-openai nil t)
  ;; (require 'ollama-buddy-claude nil t)
  ;; (require 'ollama-buddy-gemini nil t)
  ;; (require 'ollama-buddy-grok nil t)
  ;; (require 'ollama-buddy-codestral nil t)
  ;; (require 'ollama-buddy-copilot nil t)
  ;; (require 'ollama-buddy-openrouter nil t)
  ;; (require 'ollama-buddy-deepseek nil t)
  
  ;; cloud / web-search keys (not provider-managed)
  (setq ollama-buddy-cloud-api-key
        (auth-source-pick-first-password :host "ollama-buddy-cloud" :user "apikey"))
  (setq ollama-buddy-web-search-api-key
        (auth-source-pick-first-password :host "ollama-buddy-web-search" :user "apikey"))
  (setq ollama-buddy-cloud-session-token "<session-token>"

  ;; Generic provider registration (replaces individual require files)
  (require 'ollama-buddy-provider)

  (ollama-buddy-provider-create
   :name "OpenAI" :prefix "a:"
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-openai" :user "apikey"))
   :endpoint "https://api.openai.com/v1/chat/completions"
   :models-endpoint "https://api.openai.com/v1/models"
   :models-filter (lambda (id) (string-match-p "\\(gpt\\|o[0-9]\\)" id)))

  (ollama-buddy-provider-create
   :name "Claude" :prefix "c:" :api-type 'claude
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-claude" :user "apikey"))
   :endpoint "https://api.anthropic.com/v1/messages"
   :models-endpoint "https://api.anthropic.com/v1/models")

  (ollama-buddy-provider-create
   :name "Gemini" :prefix "g:" :api-type 'gemini
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-gemini" :user "apikey"))
   :endpoint "https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent"
   :models-endpoint "https://generativelanguage.googleapis.com/v1/models"
   :models-filter (lambda (id) (string-match-p "gemini" id)))

  (ollama-buddy-provider-create
   :name "Grok" :prefix "k:"
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-grok" :user "apikey"))
   :endpoint "https://api.x.ai/v1/chat/completions"
   :models-endpoint "https://api.x.ai/v1/models")

  (ollama-buddy-provider-create
   :name "Codestral" :prefix "s:"
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-codestral" :user "apikey"))
   :endpoint "https://api.mistral.ai/v1/chat/completions"
   :models '("codestral-latest"))

  (ollama-buddy-provider-create
   :name "OpenRouter" :prefix "r:"
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-openrouter" :user "apikey"))
   :endpoint "https://openrouter.ai/api/v1/chat/completions"
   :models-endpoint "https://openrouter.ai/api/v1/models"
   :extra-headers '(("HTTP-Referer" . "https://github.com/captainflasmr/ollama-buddy")
                    ("X-Title" . "ollama-buddy")))

  (ollama-buddy-provider-create
   :name "DeepSeek" :prefix "d:"
   :api-key (lambda () (auth-source-pick-first-password
                        :host "ollama-buddy-deepseek" :user "apikey"))
   :endpoint "https://api.deepseek.com/chat/completions"
   :models '("deepseek-chat" "deepseek-reasoner"))

  (require 'ollama-buddy-completion)

  (setq ollama-buddy-completion-model "qwen3-coder-next:cloud")

  ;; setup default custom menu for preferred models
  (ollama-buddy-update-menu-entry 'refactor-code     :model "minimax-m2.1:cloud")
  (ollama-buddy-update-menu-entry 'git-commit        :model "glm-4.7:cloud")
  (ollama-buddy-update-menu-entry 'describe-code     :model "minimax-m2.1:cloud")
  (ollama-buddy-update-menu-entry 'dictionary-lookup :model "minimax-m2.1:cloud")
  (ollama-buddy-update-menu-entry 'synonym           :model "minimax-m2.1:cloud")
  (ollama-buddy-update-menu-entry 'proofread         :model "minimax-m2.1:cloud")

  ;; dired integration
  (with-eval-after-load 'dired
    (define-key dired-mode-map (kbd "C-c C-a") #'ollama-buddy-dired-attach-marked-files)))

Key Bindings (Chat Buffer)

KeyAction
C-c C-cSend prompt
C-c RETSend prompt (alt)
C-c C-kCancel request
C-c mChange model
C-c lPull new model
C-c OMain transient menu
C-c ?Open Info manual
M-p / M-nBrowse prompt history
C-c MManage models
C-c LRecommended models
C-c iShow model info
C-c UMultishot
C-c NNew session
C-c fLoad session
C-c SSave session
C-c ZSessions directory
C-c JToggle history
C-c XClear history
C-c HEdit history
C-c C-aAttach file
C-c C-dDetach file
C-c aAttachment menu
C-c 0Clear all attachments
C-c C-sShow system prompt
C-c C-rReset system prompt
C-c ySystem prompts menu
C-c sUser prompts menu
C-c ~Select response tone
C-c SPCToggle tool calling
C-c GToggle unguarded mode
C-c EToggle tool auto-execute
C-c QList registered tools
C-c PProject menu
C-c pParameter menu
C-c tDisplay parameters
C-c +Settings menu
C-c rRAG menu
C-c /Web search menu
C-c xToggle streaming
C-c eSwitch backend (network/curl)
C-c !Toggle airplane mode
C-c gToggle auto-scroll
C-c AAuth menu (Cloud, Copilot)
C-c KExit/kill session

ollama API Support Tables

Core API Endpoints

API EndpointMethodPurposeSupportedNotes
/api/chatPOSTSend chat messages to a modelYesCore feature with streaming, tools, vision
/api/generatePOSTGenerate text without chat contextPartialUsed for inline completions and model unloading
/api/tagsGETList available local modelsYesUsed for model management
/api/showPOSTShow model informationYesModel info display
/api/pullPOSTPull a model from Ollama libraryYesAsync pull with progress
/api/pushPOSTPush a model to the Ollama libraryNoNot planned
/api/deleteDELETEDelete a modelYesModel management
/api/copyPOSTCopy a modelYesModel management
/api/createPOSTCreate a model from Modelfile/GGUFYesGGUF import supported
/api/psGETList running modelsYesShows loaded models in management buffer
/api/embedPOSTGenerate embeddings from textYesRAG module via ollama-buddy-rag.el (v2.5.0+)
/api/versionGETGet Ollama versionYesDisplayed on Model Management page
HEAD /api/blobs/:digestHEADCheck if blob existsNoNot needed for current functionality
POST /api/blobs/:digestPOSTPush a blobNoNot needed for current functionality
Cancel requestsCustomTerminate ongoing requestYesC-c C-k in chat buffer

Chat API Parameters (/api/chat)

ParameterSupportedNotes
modelYesPer-command or global via ollama-buddy-default-model
messagesYesFull conversation history support
toolsYesTool calling via ollama-buddy-tools.el (v2.0.0+)
thinkYesReasoning model support with visibility toggle
formatPartialJSON mode not yet exposed
optionsYesFull implementation of all model parameters
streamYesToggleable with ollama-buddy-toggle-streaming
keep_aliveYesSet via ollama-buddy-set-keepalive or ollama-buddy-keepalive

Generate API Parameters (/api/generate)

Used by ollama-buddy-completion.el for inline ghost-text completions and for model unloading.

ParameterSupportedNotes
modelYesSet via ollama-buddy-completion-model or current model
promptYesBuffer content before point (FIM prefix)
suffixYesBuffer content after point (FIM suffix)
imagesNoVision uses chat endpoint instead
formatNoNot currently exposed
optionsYesnum_predict and temperature for completions
systemYesCompletion system prompt (code-only output)
templateNoUses model defaults
streamYesStreaming enabled by default
rawNoNot currently needed
keep_aliveYesUsed for model unloading (keep_alive: 0)
contextN/ADeprecated - using messages array instead

Model Options Parameters

Parameter GroupParametersSupported
Temperature Controlstemperature, top_k, top_p, min_p, typical_pYes
Repetition Controlsrepeat_last_n, repeat_penalty, presence_penalty, frequency_penaltyYes
Advanced Samplingmirostat, mirostat_tau, mirostat_eta, penalize_newline, stopYes
Resource Managementnum_keep, seed, num_predict, num_ctx, num_batchYes
Hardware Optimizationnuma, num_gpu, main_gpu, low_vram, vocab_only, use_mmap, use_mlock, num_threadYes

Additional API Features

FeatureSupportedNotes
Streaming responsesYesDefault mode, toggleable
Tool callingYesBuilt-in tools + custom tool registration (v2.0.0+)
Vision/ImagesYesBase64 image encoding for multimodal models
Structured outputs (JSON)NoNot yet exposed
Reproducible outputs (seed)YesVia parameters
Load/Unload modelsYesVia model management buffer
Cloud modelsYesAuto-fetched from ollama.com/api/tags (v7.6+)
Thinking/Reasoning modelsYesthink parameter with visibility toggle

Roadmap

Future Considerations

Structured Outputs (JSON Schema)

The format parameter supports JSON schema for structured responses.

Implementation considerations:

  • Define output schemas per command
  • Integration with org-mode tables
  • Structured data extraction workflows

Anthropic Messages API Compatibility

Ollama v0.14+ implements /v1/messages endpoint compatible with Anthropic’s API format.

Implementation considerations:

  • Option to route Claude-format requests through local Ollama
  • Could simplify ollama-buddy-claude.el or provide fallback
  • Support for tool_use and tool_result content blocks

Image Generation Support

Ollama v0.14+ supports local image generation with models like Z-Image Turbo (6B) and FLUX.2 Klein.

Implementation considerations:

  • Detect image generation models
  • Handle image output (save to file, display in buffer)
  • Support generation parameters (width, height, steps, seed)
  • Integration with org-mode inline images

Documentation

About

A friendly Emacs interface for interacting with Ollama models

Resources

License

Stars

98 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages