gptel Atom Feed

Description
Interact with ChatGPT or other LLMs
Latest
gptel-0.9.8.0.20250531.115232.tar (.sig), 2025-May-31, 670 KiB
Maintainer
Karthik Chikmagalur <karthik.chikmagalur@gmail.com>
Website
https://github.com/karthink/gptel
Browse ELPA's repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

gptel is a simple Large Language Model chat client, with support for multiple
models and backends.

It works in the spirit of Emacs, available at any time and in any buffer.

gptel supports:

- The services ChatGPT, Azure, Gemini, Anthropic AI, Together.ai, Perplexity,
  Anyscale, OpenRouter, Groq, PrivateGPT, DeepSeek, Cerebras, Github Models,
  GitHub Copilot chat, AWS Bedrock, Novita AI, xAI, Sambanova, Mistral Le
  Chat and Kagi (FastGPT & Summarizer).
- Local models via Ollama, Llama.cpp, Llamafiles or GPT4All

Additionally, any LLM service (local or remote) that provides an
OpenAI-compatible API is supported.

Features:

- It’s async and fast, streams responses.
- Interact with LLMs from anywhere in Emacs (any buffer, shell, minibuffer,
  wherever).
- LLM responses are in Markdown or Org markup.
- Supports conversations and multiple independent sessions.
- Supports tool-use to equip LLMs with agentic capabilities.
- Supports Model Context Protocol (MCP) integration using the mcp.el package.
- Supports multi-modal models (send images, documents).
- Supports "reasoning" content in LLM responses.
- Save chats as regular Markdown/Org/Text files and resume them later.
- You can go back and edit your previous prompts or LLM responses when
  continuing a conversation.  These will be fed back to the model.
- Redirect prompts and responses easily
- Rewrite, refactor or fill in regions in buffers.
- Write your own commands for custom tasks with a simple API.

Requirements for ChatGPT, Azure, Gemini or Kagi:

- You need an appropriate API key.  Set the variable `gptel-api-key' to the
  key or to a function of no arguments that returns the key.  (It tries to
  use `auth-source' by default)

ChatGPT is configured out of the box.  For the other sources:

- For Azure: define a gptel-backend with `gptel-make-azure', which see.
- For Gemini: define a gptel-backend with `gptel-make-gemini', which see.
- For Anthropic (Claude): define a gptel-backend with `gptel-make-anthropic',
  which see.
- For Together.ai, Anyscale, Groq, OpenRouter, DeepSeek, Cerebras or
  Github Models: define a gptel-backend with `gptel-make-openai', which see.
- For PrivateGPT: define a backend with `gptel-make-privategpt', which see.
- For Perplexity: define a backend with `gptel-make-perplexity', which see.
- For Deepseek: define a backend with `gptel-make-deepseek', which see.
- For Kagi: define a gptel-backend with `gptel-make-kagi', which see.

For local models using Ollama, Llama.cpp or GPT4All:

- The model has to be running on an accessible address (or localhost)
- Define a gptel-backend with `gptel-make-ollama' or `gptel-make-gpt4all',
  which see.
- Llama.cpp or Llamafiles: Define a gptel-backend with `gptel-make-openai'.

Consult the package README for examples and more help with configuring
backends.

Usage:

gptel can be used in any buffer or in a dedicated chat buffer.  The
interaction model is simple: Type in a query and the response will be
inserted below.  You can continue the conversation by typing below the
response.

To use this in any buffer:

- Call `gptel-send' to send the buffer's text up to the cursor.  Select a
  region to send only the region.

- You can select previous prompts and responses to continue the conversation.

- Call `gptel-send' with a prefix argument to access a menu where you can set
  your backend, model and other parameters, or to redirect the
  prompt/response.

To use this in a dedicated buffer:

- M-x gptel: Start a chat session.

- In the chat session: Press `C-c RET' (`gptel-send') to send your prompt.
  Use a prefix argument (`C-u C-c RET') to access a menu.  In this menu you
  can set chat parameters like the system directives, active backend or
  model, or choose to redirect the input or output elsewhere (such as to the
  kill ring or the echo area).

- You can save this buffer to a file.  When opening this file, turn on
  `gptel-mode' before editing it to restore the conversation state and
  continue chatting.

- To include media files with your request, you can add them to the context
  (described next), or include them as links in Org or Markdown mode chat
  buffers.  Sending media is disabled by default, you can turn it on globally
  via `gptel-track-media', or locally in a chat buffer via the header line.

Include more context with requests:

If you want to provide the LLM with more context, you can add arbitrary
regions, buffers, files or directories to the query with `gptel-add'.  To add
text or media files, call `gptel-add' in Dired or use the dedicated
`gptel-add-file'.

You can also add context from gptel's menu instead (`gptel-send' with a
prefix arg), as well as examine or modify context.

When context is available, gptel will include it with each LLM query.

LLM Tool use:

gptel supports "tool calling" behavior, where LLMs can specify arguments with
which to call provided "tools" (elisp functions).  The results of running the
tools are fed back to the LLM, giving it capabilities and knowledge beyond
what is available out of the box.  For example, tools can perform web
searches or API lookups, modify files and directories, and so on.

Tools can be specified via `gptel-make-tool', or obtained from other
repositories, or from Model Context Protocol (MCP) servers using the mcp.el
package.  See the README for details.

Tools can be included with LLM queries using gptel's menu, or from
`gptel-tools'.

Rewrite interface

In any buffer: with a region selected, you can rewrite prose, refactor code
or fill in the region.  This is accessible via `gptel-rewrite', and also from
the `gptel-send' menu.

Presets

Define a bundle of configuration (model, backend, system message, tools etc)
as a "preset" that can be applied together, making it easy to switch between
tasks in gptel.  Presets can be saved and applied from gptel's transient
menu.  You can also include a cookie of the form "@preset-name" in the prompt
to send a request with a preset applied.  This feature works everywhere, but
preset cookies are also fontified in chat buffers.

gptel in Org mode:

gptel offers a few extra conveniences in Org mode:

- You can limit the conversation context to an Org heading with
  `gptel-org-set-topic'.
  
- You can have branching conversations in Org mode, where each hierarchical
  outline path through the document is a separate conversation branch.
  See the variable `gptel-org-branching-context'.
  
- You can declare the gptel model, backend, temperature, system message and
  other parameters as Org properties with the command
  `gptel-org-set-properties'.  gptel queries under the corresponding heading
  will always use these settings, allowing you to create mostly reproducible
  LLM chat notebooks.

Finally, gptel offers a general purpose API for writing LLM ineractions that
suit your workflow.  See `gptel-request', and `gptel-fsm' for more advanced
usage.

Old versions

gptel-0.9.8.0.20250530.235851.tar.lz2025-May-31 124 KiB
gptel-0.9.8.0.20250529.230850.tar.lz2025-May-30 114 KiB
gptel-0.9.8.0.20250528.92841.tar.lz2025-May-28 114 KiB
gptel-0.9.8.0.20250519.123354.tar.lz2025-May-19 113 KiB
gptel-0.9.8.0.20250424.171502.tar.lz2025-Apr-25 107 KiB
gptel-0.9.8.0.20250331.142420.tar.lz2025-Apr-01 103 KiB
gptel-0.9.7.0.20250313.122929.tar.lz2025-Mar-13 103 KiB
gptel-0.9.0.0.20241010.94430.tar.lz2024-Oct-1061.4 KiB
gptel-0.8.6.0.20240623.113847.tar.lz2024-Jun-2357.2 KiB
gptel-0.8.5.0.20240429.130547.tar.lz2024-May-0149.1 KiB

News

# -*- mode: org; -*-

* 0.9.9

** Breaking changes

- ~gptel-org-branching-context~ is now a global variable.  It was
  buffer-local by default in past releases.

- The following models have been removed from the default ChatGPT backend:
  - ~o1-preview~: use ~o1~ instead.
  - ~gpt-4-turbo-preview~: use ~gpt-4o~ or ~gpt-4-turbo~ instead.
  - ~gpt-4-32k~, ~gpt-4-0125-preview~ and ~gpt-4-1106-preview~: use
    ~gpt-4o~ or ~gpt-4~ instead.
  Alternatively, you can add these models back to the backend in your
  personal configuration:
  #+begin_src emacs-lisp
  (push 'gpt-4-turbo-preview
        (gptel-backend-models (gptel-get-backend "ChatGPT")))
  #+end_src

** New models and backends

- Add support for ~gpt-4.1~, ~gpt-4.1-mini~, ~gpt-4.1-nano~, ~o3~ and
  ~o4-mini~.

- Add support for ~gemini-2.5-pro-exp-03-25~,
  ~gemini-2.5-flash-preview-04-17~ and ~gemini-2.5-pro-preview-05-06~.

- Add support for ~claude-sonnet-4-20250514~ and
  ~claude-opus-4-20250514~.

- Add support for AWS Bedrock models.  You can create an AWS Bedrock
  gptel backend with ~gptel-make-bedrock~, which see.  Please note:
  AWS Bedrock support requires Curl 8.5.0 or higher.

- You can now create an xAI backend with ~gptel-make-xai~, which see.
  (xAI was supported before but the model configuration is now handled
  for you by this function.)

- Add support for GitHub Copilot Chat.  See the README and
  ~gptel-make-gh-copilot~.  Please note: this is only the chat
  component of GitHub Copilot.  Copilot's ~completion-at-point~
  (tab-completion) functionality is not supported by gptel.

- Add support for Sambanova.  This is an OpenAI-compatible API so you
  can create a backend with ~gptel-make-openai~, see the README for
  details.

- Add support for Mistral Le Chat.  This is an an OpenAI-compatible
  API so you can create a backend with ~gptel-make-openai~, see the
  README for details.

** New features and UI changes

- gptel now supports handling reasoning/thinking blocks in responses
  from Gemini models.  This is controlled by
  ~gptel-include-reasoning~, in the same way that it handles other
  APIs.

- The new option ~gptel-curl-extra-args~ can be used to specify extra
  arguments to the Curl command used for the request.  This is the
  global version of the gptel-backend-specific ~:curl-args~ slot,
  which can be used to specify Curl arguments when using a specific
  backend.

- Tools now run in the buffer from which the request originates.  This
  can be significant when tools read or manipulate Emacs' state.

- gptel can access MCP server tools by integrating with the mcp.el
  package, which is at https://github.com/lizqwerscott/mcp.el.
  (mcp.el is not yet available in a package archive.)  To help with
  the integration, two new commands are provided: ~gptel-mcp-connect~
  and ~gptel-mcp-disconnect~.  You can use these to start MCP servers
  selectively and add tools to gptel.  These commands are also
  available from gptel's tools menu.
  
  These commands are currently not autoloaded by gptel.  To access
  them, require the ~gptel-integrations~ feature.

- You can now define "presets", which are a bundle of gptel options,
  such as the backend, model, system message, included tools,
  temperature and so on.  This set of options can be applied together,
  making it easy to switch between different tasks using gptel.  From
  gptel's transient menu, you can save the current configuration as a
  preset or apply another one.  Presets can be applied globally,
  buffer-locally or for the next request only.  To persist presets
  across Emacs sessions, define presets in your configuration using
  ~gptel-make-preset~.

- When using ~gptel-send~ from anywhere in Emacs, you can now include
  a "cookie" of the form =@preset-name= in the prompt text to apply
  that preset before sending.  The preset is applied for that request
  only.  This is an easy way to switch models, tools, system
  messages (etc) on the fly.  In chat buffers the preset cookie is
  fontified and available for completion via ~completion-at-point~.
...
...