diff --git a/gptel-curl.el b/gptel-curl.el index 7953790..4f2348f 100644 --- a/gptel-curl.el +++ b/gptel-curl.el @@ -50,7 +50,8 @@ PROMPTS is the data to send, TOKEN is a unique identifier." (api-key (cond ((stringp gptel-api-key) gptel-api-key) - ((functionp gptel-api-key) (funcall gptel-api-key)))) + ((functionp gptel-api-key) (funcall gptel-api-key)) + (t (setq gptel-api-key (read-passwd "OpenAI API key: "))))) (headers `(("Content-Type" . "application/json") ("Authorization" . ,(concat "Bearer " api-key))))) diff --git a/gptel.el b/gptel.el index f93f44c..b90bf54 100644 --- a/gptel.el +++ b/gptel.el @@ -278,7 +278,8 @@ Return the message received." (api-key (cond ((stringp gptel-api-key) gptel-api-key) - ((functionp gptel-api-key) (funcall gptel-api-key)))) + ((functionp gptel-api-key) (funcall gptel-api-key)) + (t (setq gptel-api-key (read-passwd "OpenAI API key: "))))) (url-request-method "POST") (url-request-extra-headers `(("Content-Type" . "application/json")