Skip to content

How do I assign backends & models to buffers programmatically? #500

Answered by karthink
tomb7890 asked this question in Q&A
Discussion options

You must be logged in to vote

You are looking for setq-local.

(defun my/initialize-google-gemini ()
  "Set up gptel for use with Google Gemini."
  (interactive)
  (let ((api-key (password-store-get "google-gemini") ))
    (setq-local
     gptel-model 'gemini-1.5-pro-latest
     gptel-backend (gptel-make-gemini "Gemini"
                      :key api-key
                      :stream t))))
 
(defun my/initialize-chatgpt-4o-mini ()
  "Set up gptel for use with ChatGPT."
  (interactive)
  (setq-local gptel-api-key (password-store-get-field "openai" "apikey"))
  (setq-local gptel-model 'gpt-4o-mini))

Just remember to call this with the relevant buffer as the current one, for example via some hook.

It used to be that setti…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tomb7890
Comment options

Answer selected by tomb7890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants