k8sgpt
k8sgpt copied to clipboard
Error: failed while calling AI provider openai: error, status code: 401, message:
Checklist
- [X] I've searched for similar issues and couldn't find anything matching
- [X] I've included steps to reproduce the behavior
Affected Components
- [X] K8sGPT (CLI)
- [X] K8sGPT Operator
K8sGPT Version
0.3.6
Kubernetes Version
No response
Host OS and its Version
mac
Steps to reproduce
- k8sgpt analyse (works as expected)
- k8sgpt analyse --explain. (Doesn't works asking for key)
Expected behaviour
Expectect to show all the details of the cluster/pod issues
Actual behaviour
Error: failed while calling AI provider openai: error, status code: 401, message: You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.
Additional Information
Error: failed while calling AI provider openai: error, status code: 401, message: You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.
I have already add api key, where do I'm missing for header? I don't see any documentation around this
Which command did you use to add the API key?
I also have this problem. I properly created a new API key by running k8sgpt generated which took me to API keys page where I created and copied a new key. I then pasted that when prompted in the next command
❯ k8sgpt auth add openai Warning: backend input is empty, will use the default value: openai Warning: model input is empty, will use the default value: gpt-3.5-turbo Enter openai Key: openai added to the AI backend provider list
❯ k8sgpt analyze --explain 0% | | (0/2, 0 it/hr) [0s:0s] Error: failed while calling AI provider openai: error, status code: 401, message: Incorrect API key provided: sk-2jiZn*********************************************************************************************************************************************mV7h. You can find your API key at https://platform.openai.com/account/api-keys.
What is wrong. I can use GPT 4 already and have subscription.
@radrad that's odd, do you see the api key in your k8sgpt config file ?
@radrad that's odd, do you see the api key in your k8sgpt config file ?
where is this config file located? I am using windows 10. I added this folder to system path env variable "j:\Tools\k8sgpt" I cannot see any config file being created in that folder as well as %userprofile% (C:\Users<username>) Where is this openai key persisted?
Good question, I haven't used Windows in a while but we write the configuration in your XDG_CONFIG_HOME directory
I think it should be under your LocalAppData folder
I have the same issue on my mac. Where is the config file located ?
I have the same issue on my mac. Where is the config file located ? I found mine on windows: C:\Users<user>\AppData\Local\k8sgpt
I noticee multiple provider entries with the same name and strange 3X concatenated API key in the first provider. I think there is a bug in duplicating provider names. Regarding first provider with 3X concatenation you can ignore it. It could be that in one case I was pressing Ctrl+V 3 times (not used to empty feedback when pasting something in cmd window. My configuration with sensitive info reduced: ai: providers: - name: openai model: "" password: <sk-something...H1ax2nZ6ZssVmm><sk-something...H1ax2nZ6ZssVmm><sk-something...H1ax2nZ6ZssVmm> temperature: 0.7 - name: openai model: "" password: sk-....Something 2 temperature: 0.7 - name: openai model: "" password: '"<sk-something...H1ax2nZ6ZssVmm>"' temperature: 0.7 - name: openai model: "" password: <sk-something...H1ax2nZ6ZssVmm> temperature: 0.7 - name: openai model: "" password: <sk-something...H1ax2nZ6ZssVld> temperature: 0.7 defaultprovider: "" kubeconfig: "" kubecontext: ""
I asked GTP chat-4: what is equivalent on mac and linux for this windows locaton:
The equivalent path on a Mac would be /Users/
I removed all but the first entry and here is my settings. It works now: ai: providers: - name: openai model: "gpt-4-1106-preview" password: "sk-......" temperature: 0.7 defaultprovider: "openai" kubeconfig: "" kubecontext: ""
I had the same issue in Ubunto with WSL, I re-tried with multiple keys , eventually moved azureOpenai which worked well from the start.
Anyone know this fix to this error: Error: failed while calling AI provider openai: Post "https://api.openai.com/v1/chat/completions": net/http: invalid header field value for "Authorization"
Installed g8sgpt on my wsl and connected with openai backend $k8sgpt generate Opening: https://beta.openai.com/account/api-keys to generate a key for openai
Please copy the generated key and run k8sgpt auth
to add it to your config file
$k8sgpt auth add --backend openai --model gpt-3.5-turbo
Enter openai Key: openai added to the AI backend provider list
Now When I am running below command getting cert issue.. $k8sgpt analyse --explain 0% | | (0/1, 0 it/hr) [0s:0s] Error: failed while calling AI provider openai: Post "https://api.openai.com/v1/chat/completions": tls: failed to verify certificate: x509: certificate signed by unknown authority
Any help would be appreciated....
@kamleshjec which k8sgpt version are you using?
Thanks a lot for your response, Its working for me now, I am using azureopenai instead openai as there was some issue with default auth ai backend I mean when I was running k8sgpt generate cmd it was redirecting for openai key which was having some issue.