diff --git a/gptel-curl.el b/gptel-curl.el index 23cd597..e0f9e0c 100644 --- a/gptel-curl.el +++ b/gptel-curl.el @@ -41,7 +41,8 @@ "Produce list of arguments for calling Curl. PROMPTS is the data to send, TOKEN is a unique identifier." - (let* ((url (format "https://%s/v1/chat/completions" gptel-host)) + (let* ((url (format "%s://%s/v1/chat/completions" + gptel-protocol gptel-host)) (data (encode-coding-string (json-encode (gptel--request-data prompts)) 'utf-8)) diff --git a/gptel.el b/gptel.el index 287e64e..fca068c 100644 --- a/gptel.el +++ b/gptel.el @@ -86,6 +86,9 @@ :group 'gptel :type 'string) +(defvar gptel-protocol "https" + "Protocol used to query `gptel-host'.") + (defcustom gptel-proxy "" "Path to a proxy to use for gptel interactions. Passed to curl via --proxy arg, for example \"proxy.yourorg.com:80\" @@ -774,7 +777,7 @@ the response is inserted into the current buffer after point." (encode-coding-string (json-encode (gptel--request-data (plist-get info :prompt))) 'utf-8))) - (url-retrieve (format "https://%s/v1/chat/completions" gptel-host) + (url-retrieve (format "%s://%s/v1/chat/completions" gptel-protocol gptel-host) (lambda (_) (pcase-let ((`(,response ,http-msg ,error) (gptel--url-parse-response (current-buffer))))