Function: gptel-api-key-from-auth-source

gptel-api-key-from-auth-source is a natively compiled function defined in gptel-request.el.

Signature

(gptel-api-key-from-auth-source &optional HOST USER)

Documentation

Lookup api key in the auth source.

By default, the LLM host for the active backend is used as HOST, and "apikey" as USER.

Source Code

;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
;;;; Misc utilities
(defun gptel-api-key-from-auth-source (&optional host user)
  "Lookup api key in the auth source.
By default, the LLM host for the active backend is used as HOST,
and \"apikey\" as USER."
  (if-let* ((secret
             (plist-get
              (car (auth-source-search
                    :host (or host (gptel-backend-host gptel-backend))
                    :user (or user "apikey")
                    :require '(:secret)))
              :secret)))
      (if (functionp secret)
          (encode-coding-string (funcall secret) 'utf-8)
        secret)
    (user-error "No `gptel-api-key' found in the auth source")))