Skip to content

Commit

Permalink
Add support for auth-source secret functions to :key argument (#111)
Browse files Browse the repository at this point in the history
Partially implements #110
  • Loading branch information
minad authored Nov 28, 2024
1 parent b7787a3 commit 315aace
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llm-openai.el
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ PROVIDER is the Open AI provider struct."

(cl-defmethod llm-openai--headers ((provider llm-openai))
(when-let ((key (llm-openai-key provider)))
;; If the key is a function, call it. The `auth-source' API uses functions
;; to wrap secrets and to obfuscate them in the Emacs heap.
(when (functionp key)
(setq key (funcall key)))
;; Encode the API key to ensure it is unibyte. The request library gets
;; confused by multibyte headers, which turn the entire body multibyte if
;; there’s a non-ascii character, regardless of encoding. And API keys are
Expand Down

0 comments on commit 315aace

Please sign in to comment.