Function: gptel-send

gptel-send is an interactive and natively compiled function defined in gptel.el.

Signature

(gptel-send &optional ARG)

Documentation

Submit this prompt to the current LLM backend.

By default, the contents of the buffer up to the cursor position are sent. If the region is active, its contents are sent instead.

The response from the LLM is inserted below the cursor position at the time of sending.

To change this behavior, model parameters, or interact with a query already in progress, use prefix arg ARG:

- Use a prefix arg of C-u (universal-argument) to bring up a menu with
  more options.

- Use a prefix arg of 0 to add more instructions to a request already in
  progress. The instructions are read from the active region, or from
  text entered below an ongoing response. This is sent when the LLM
  next makes tool calls, so if no tools are provided or called the
  additional instructions are ignored.

This command is asynchronous, you can continue to use Emacs while waiting for the response.

Key Bindings

gptel-mode-map C-c RET

Source Code

;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
;;; Send queries, handle responses
;;;###autoload
(defun gptel-send (&optional arg)
  "Submit this prompt to the current LLM backend.

By default, the contents of the buffer up to the cursor position
are sent.  If the region is active, its contents are sent
instead.

The response from the LLM is inserted below the cursor position
at the time of sending.

To change this behavior, model parameters, or interact with a query
already in progress, use prefix arg ARG:

- Use a prefix arg of \\[universal-argument] to bring up a menu with
  more options.

- Use a prefix arg of 0 to add more instructions to a request already in
  progress.  The instructions are read from the active region, or from
  text entered below an ongoing response.  This is sent when the LLM
  next makes tool calls, so if no tools are provided or called the
  additional instructions are ignored.

This command is asynchronous, you can continue to use Emacs while
waiting for the response."
  (interactive "P")
  (pcase arg
    (0 (gptel-send--steer))
    ('(4) (require 'gptel-transient nil t) (call-interactively #'gptel-menu))
    (_
     (let ((fsm (gptel-make-fsm :table gptel-send--transitions
                                :handlers gptel-send--handlers)))
       (gptel-request nil
         :stream gptel-stream
         :transforms gptel-prompt-transform-functions
         :fsm fsm)
       (message "Querying %s..."
                (thread-first (gptel-fsm-info fsm)
                              (plist-get :backend)
                              (or gptel-backend)
                              (gptel-backend-name))))
     (gptel--update-status " Waiting..." 'warning))))