Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load api key from ~\.authinfo #418

Open
tsoernes opened this issue Oct 12, 2024 · 6 comments
Open

Cannot load api key from ~\.authinfo #418

tsoernes opened this issue Oct 12, 2024 · 6 comments
Labels
question Further information is requested

Comments

@tsoernes
Copy link

I have this config in doom emacs

(setq-default gptel-model 'm-gpt-4o-mini-18072024)
(setq gptel-backend (gptel-make-azure "Azure-1-GPT-4o-mini"
                      :protocol "https"
                      :host "<MY_HOST>.openai.azure.com"
                      :endpoint "/openai/deployments/m-gpt-4o-mini-18072024/chat/completions?api-version=2024-08-01-preview"
                      :stream t
                      :key #'gptel-api-key-from-auth-source
                      :models '(m-gpt-4o-mini-18072024)))

Is this correct?
Cause I have the file
~/.authinfo with

machine api.openai.com login apikey password <MY_TOKEN>

But I'm asked for a GPT API key every time I open gptel.

@karthink
Copy link
Owner

What happens if you run (gptel-api-key-from-auth-source)? Does it return the key?

@tsoernes
Copy link
Author

tsoernes commented Oct 15, 2024 via email

@tschwinge
Copy link

I suppose the problem is that your ~/.authinfo's machine api.openai.com doesn't match your gptel-backend's :host "<MY_HOST>.openai.azure.com"?

@karthink
Copy link
Owner

@tsoernes gptel-api-key-from-auth-source looks up the :host in your authinfo. So the authinfo entry should look like

machine <MY_HOST>.openai.azure.com login apikey password <MY_TOKEN>

OR

You can write your own function that looks up the right key in your authinfo and use that in place of gptel-api-key-from-auth-source.

@glubbfreund
Copy link

glubbfreund commented Oct 18, 2024

im not sure If I should answer here but I have the same Issue except with ChatGPT. Do you use windows? It doesnt find the file in windows but within WSL2 it works with just the same config and .authinfo file. Seems to be a path issue on my side.

It works on both systems if I use the following approach:

(require 'gptel)
(setq auth-sources '("~/.authinfo"))
(setq gptel-api-key (auth-source-pick-first-password :host "api.openai.com"))

@karthink karthink added the question Further information is requested label Oct 24, 2024
@karthink
Copy link
Owner

@tsoernes Does my above reply work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants