# karthink/gptel

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/karthink-gptel).**

3,192 stars · 360 forks · Emacs Lisp · gpl-3.0

## Links

- GitHub: https://github.com/karthink/gptel
- awesome-repositories: https://awesome-repositories.com/repository/karthink-gptel.md

## Topics

`chatgpt` `emacs` `llms` `org-mode`

## Description

gptel is an LLM Emacs client and multi-backend AI integration system that allows users to interact with large language models directly inside the Emacs text editor. It serves as an AI-powered text refactoring tool and a context-aware prompt manager, providing a unified interface to connect with various AI providers, including local Ollama instances, AWS Bedrock, and Gemini.

The project distinguishes itself as a Model Context Protocol client, connecting to MCP servers to provide language models with external tools and data sources. It enables context-augmented prompting by aggregating text from buffers, files, and multimedia as supplementary knowledge for model requests.

The system covers a broad range of capabilities, including AI-assisted coding for rewriting and refactoring text within buffers, and AI conversation management for maintaining persistent, branched chat sessions. It also includes support for multi-modal input processing, tool-call dispatching for executing local shell commands or editor actions, and identity verification via OAuth 2.0 and device authorization flows.

The client tracks resource consumption through token usage monitoring and provides diagnostic tools for API request debugging.

## Tags

### Development Tools & Productivity

- [LLM Clients](https://awesome-repositories.com/f/development-tools-productivity/emacs-extensions/llm-clients.md) — Provides a comprehensive interface for interacting with large language models directly inside Emacs.
- [AI Coding Assistants](https://awesome-repositories.com/f/development-tools-productivity/ai-coding-assistants.md) — Integrates LLMs into the editor to automate code generation and refactoring directly within buffers.
- [Buffer Manipulations](https://awesome-repositories.com/f/development-tools-productivity/buffer-manipulations.md) — Provides deep integration with editor buffers to read and modify text content directly. ([source](https://github.com/karthink/gptel/wiki/Tools-collection))
- [Refactoring Tools](https://awesome-repositories.com/f/development-tools-productivity/refactoring-tools.md) — Serves as a tool for rewriting and refactoring AI-generated code and text within the editor.
- [Session Persistence Buffers](https://awesome-repositories.com/f/development-tools-productivity/text-buffer-manipulations/buffer-based-storage/session-persistence-buffers.md) — Stores conversation histories and model configurations as structured text within editor buffers for state recovery.
- [Iterative Rewriting](https://awesome-repositories.com/f/development-tools-productivity/text-object-selection/text-block-movement/text-merging/iterative-rewriting.md) — Ships a preview system for iteratively refining and merging AI-generated text and code suggestions. ([source](https://github.com/karthink/gptel/blob/master/README.org))
- [Copilot API Integrations](https://awesome-repositories.com/f/development-tools-productivity/github-api-integrations/copilot-api-integrations.md) — Integrates with the GitHub Copilot API to utilize large language models for AI-assisted tasks within the editor. ([source](https://github.com/karthink/gptel/blob/master/gptel-gh.el))
- [Shell Command Execution](https://awesome-repositories.com/f/development-tools-productivity/shell-command-execution.md) — Runs system shell commands synchronously or asynchronously and captures the output as text for the AI. ([source](https://github.com/karthink/gptel/wiki/Tools-collection))

### Software Engineering & Architecture

- [AI Backend Abstractions](https://awesome-repositories.com/f/software-engineering-architecture/execution-backend-abstractions/ai-backend-abstractions.md) — Provides a unified configuration interface to swap between various LLM providers including local Ollama and cloud APIs.
- [Context Aggregators](https://awesome-repositories.com/f/software-engineering-architecture/application-frameworks/single-file-backend-servers/single-file-executables/context-aggregators.md) — Collects and flattens text from buffers, files, and regions into a single stream for model ingestion. ([source](https://github.com/karthink/gptel/blob/master/gptel-context.el))
- [Prompt Context Aggregators](https://awesome-repositories.com/f/software-engineering-architecture/context-aware-tooling/prompt-context-aggregators.md) — Aggregates files, buffers, and multimedia as supplementary context to manage and enrich LLM requests.
- [Prompt Context Injectors](https://awesome-repositories.com/f/software-engineering-architecture/external-content-handlers/external-content-inclusions/prompt-context-injectors.md) — Provides mechanisms for referencing files, buffers, and text regions directly in prompts to provide a live knowledge base. ([source](https://github.com/karthink/gptel#readme))
- [Prompt Presets](https://awesome-repositories.com/f/software-engineering-architecture/project-management-governance/project-management/project-lifecycle-management/project-configuration-presets/configuration-presets/prompt-presets.md) — Manages predefined sets of system instructions and model settings to guide AI behavior. ([source](https://github.com/karthink/gptel/blob/master/README.org))

### Artificial Intelligence & ML

- [AI Backend Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-backend-integrations.md) — Provides mechanisms for connecting the interface to various AI providers and custom backends using API keys or OAuth. ([source](https://github.com/karthink/gptel/blob/master/NEWS))
- [AI Conversation Managers](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-conversation-managers.md) — Manages independent chat sessions with the ability to edit history to steer model behavior. ([source](https://github.com/karthink/gptel/blob/master/gptel.el))
- [LLM Tooling Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/artificial-intelligence-tooling/language-model-integrations/llm-tooling-integrations.md) — Provides the language model with internal functions for filesystem access and editor state introspection. ([source](https://github.com/karthink/gptel/blob/master/NEWS))
- [Client-Side Tool Execution](https://awesome-repositories.com/f/artificial-intelligence-ml/client-side-tool-execution.md) — Executes internal editor functions as callbacks triggered by language model tool requests. ([source](https://github.com/karthink/gptel#readme))
- [Context Augmentation Tools](https://awesome-repositories.com/f/artificial-intelligence-ml/context-augmentation-tools.md) — Aggregates information from files, buffers, and web content to build a live knowledge base for prompts.
- [External Tool Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/external-service-integrations/external-knowledge-integrators/external-tool-integrations.md) — Connects language models to external capabilities and protocols to extend their functional reach. ([source](https://github.com/karthink/gptel/blob/master/gptel.el))
- [LLM API Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/llm-api-integrations.md) — Integrates with external large language model providers to send prompts and receive generated text responses. ([source](https://github.com/karthink/gptel/blob/master/gptel-kagi.el))
- [LLM Provider Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/llm-provider-integrations.md) — Provides authentication adapters and connectivity for various LLM providers including Ollama, Gemini, and AWS Bedrock.
- [Model Backend Registrations](https://awesome-repositories.com/f/artificial-intelligence-ml/model-backend-registrations.md) — Implements a mechanism for registering and integrating various AI model backends through a standardized generation interface. ([source](https://github.com/karthink/gptel/blob/master/README.org))
- [Model Context Protocol Clients](https://awesome-repositories.com/f/artificial-intelligence-ml/model-context-protocol-clients.md) — Implements a client that connects to Model Context Protocol servers to provide AI models with external tools and data.
- [Tool Call Interception Middleware](https://awesome-repositories.com/f/artificial-intelligence-ml/tool-call-interception-middleware.md) — Intercepts AI tool calls to execute local shell commands or editor actions within the Emacs environment.
- [Agent File Attachments](https://awesome-repositories.com/f/artificial-intelligence-ml/agent-file-attachments.md) — Provides mechanisms for attaching documents or images to AI prompts via local paths or URLs. ([source](https://github.com/karthink/gptel/blob/master/README.org))
- [Ollama Engine Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-application-frameworks/local-on-device-ai/ollama-engine-integrations.md) — Integrates with the Ollama engine to send prompts and receive responses from locally hosted AI models. ([source](https://github.com/karthink/gptel/blob/master/gptel-ollama.el))
- [Conversation Branching Systems](https://awesome-repositories.com/f/artificial-intelligence-ml/conversation-history-management/conversation-branching-systems.md) — Implements hierarchical organization to maintain divergent, branched conversation threads. ([source](https://github.com/karthink/gptel#readme))
- [Outline-Based Branching](https://awesome-repositories.com/f/artificial-intelligence-ml/conversation-history-management/conversation-branching-systems/outline-based-branching.md) — Leverages Org-mode headings and properties to isolate topics and structure branched conversations. ([source](https://github.com/karthink/gptel/blob/master/README.org))
- [Conversation Branching](https://awesome-repositories.com/f/artificial-intelligence-ml/conversational-session-management/multi-session-context-synthesizers/session-history-retrieval/conversation-branching.md) — Implements a system for branching AI conversations into divergent paths using editor document structures.
- [Gemini Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/gemini-integrations.md) — Connects to the Gemini AI platform to exchange prompts and text responses while tracking token usage. ([source](https://github.com/karthink/gptel/blob/master/gptel-gemini.el))
- [Model Context Protocol Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/model-context-protocol-integrations.md) — Implements the Model Context Protocol to provide AI models with access to external tools and data sources. ([source](https://github.com/karthink/gptel/blob/master/gptel-integrations.el))
- [System Prompt Configurations](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-engineering/system-configuration-layers/system-prompt-configurations.md) — Defines persistent system prompts and instructions to establish the persona and behavior of the model. ([source](https://github.com/karthink/gptel/blob/master/NEWS))
- [Structured Output Enforcements](https://awesome-repositories.com/f/artificial-intelligence-ml/structured-output-enforcements.md) — Constrains AI responses to a specific JSON schema when making programmatic requests to ensure consistent data formats. ([source](https://github.com/karthink/gptel/blob/master/NEWS))
- [Token Usage Monitoring](https://awesome-repositories.com/f/artificial-intelligence-ml/text-tokenizers/tokenized-file-managers/token-aware-aggregators/token-usage-monitoring.md) — Tracks and displays the count of tokens sent and received in the interface header.
- [Incremental Result Streaming](https://awesome-repositories.com/f/artificial-intelligence-ml/tool-calling-integration-frameworks/tool-output-processors/incremental-result-streaming.md) — Processes incoming data streams to incrementally display AI-generated text, reasoning summaries, and tool execution results. ([source](https://github.com/karthink/gptel/blob/master/gptel-openai-responses.el))

### Part of an Awesome List

- [AI-Driven Refactoring](https://awesome-repositories.com/f/awesome-lists/devtools/ai-driven-refactoring.md) — Uses generative AI to rewrite or fill in specific regions of text and code within buffers. ([source](https://github.com/karthink/gptel/blob/master/gptel.el))

### Security & Cryptography

- [Named Session Save and Restore](https://awesome-repositories.com/f/security-cryptography/process-sandboxes/session-resumption/ai-agent-sessions/named-session-save-and-restore.md) — Implements named saving and restoring of full conversation histories to local files. ([source](https://github.com/karthink/gptel/blob/master/README.org))

### DevOps & Infrastructure

- [AWS Bedrock Integrations](https://awesome-repositories.com/f/devops-infrastructure/aws-bedrock-integrations.md) — Integrates with AWS Bedrock AI services to send prompts and receive model responses using a standardized structure. ([source](https://github.com/karthink/gptel/blob/master/gptel-bedrock.el))

### Networking & Communication

- [Buffer-to-Prompt Streaming](https://awesome-repositories.com/f/networking-communication/streaming-data-integrations/prompt-streaming/buffer-to-prompt-streaming.md) — Sends text from the current cursor position or selected region to an AI and inserts the response directly into the buffer. ([source](https://github.com/karthink/gptel/blob/master/README.org))

### System Administration & Monitoring

- [Token Usage Analytics](https://awesome-repositories.com/f/system-administration-monitoring/usage-monitoring/token-usage-analytics.md) — Tracks and displays the number of tokens sent and received directly in the interface header. ([source](https://github.com/karthink/gptel/blob/master/NEWS))

### User Interface & Experience

- [Incremental Text Rendering](https://awesome-repositories.com/f/user-interface-experience/incremental-text-rendering.md) — Updates the editor interface in real-time as AI text chunks and reasoning blocks are streamed.

### Web Development

- [Multi-Modal Handlers](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling/multi-modal-response-handlers/multi-modal-handlers.md) — Implements handlers for processing and exchanging heterogeneous multi-modal content between the editor and AI providers. ([source](https://github.com/karthink/gptel/blob/master/gptel.el))
