Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This looks great. However, after generting an API key and providing it to chatblade, I get the following error:

openai.error.AuthenticationError: Incorrect API key provided: user@dom***.tld. You can find your API key at https://platform.openai.com/account/api-keys.

That is kind of weird, because the email given in that message looks valid, but does not match my OpenAI account name. Is that email encoded in the key? If so, apparently decoding worked, so why should the key be invalid?

Am I doing something wrong here, or is something round the API key stuff broken right now?



It looks like user@dom**.tld is actually what you set as your key.

I can generate the same error by setting

OPENAI_API_KEY="this is wrong"; chatblade test

openai.error.AuthenticationError: Incorrect API key provided: this is *rong. You can find your API key at https://platform.openai.com/account/api-keys.

if you run

echo $OPENAI_API_KEY

you should see your key which starts with sk-......... If not thats where your issue is


That is what is strange about it, OPENAI_API_KEY is set correctly, and start with sk-

So I wonder where it is getting this email from.


can you try:

curl https://api.openai.com/v1/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{ "model": "text-davinci-003", "prompt": "Say this is a test", "max_tokens": 7, "temperature": 0 }'


Yes, this works.

So my api key is valid. But something in chatblade or the python packages it depends on trashes the input I provide, and replaces it with an email address of mine. Sounds weird, but is apparently true.


Its not doing anything special that could "trash" the input. In fact no other env variables are read at all. So the fact that you are seeing your email, is a pretty strong indication that it is being set by you somewhere. Where else could it even get it from?

An other option is that you passed your email as a parameter mistakingly (which takes precedence over the env variable)

But the code is really pretty simple. https://github.com/npiv/chatblade/blob/4ce28739ca7ada1611029...


Found it! I need to set NETRC=/dev/null. It appears the request library is trying to grab auth info from .netrc, and in my case, picks the default entry. Why it is doing that despite an api key being provided is unclear.


The openapi library seems to use requests incorrectly.

> If no authentication method is given with the auth argument, Requests will attempt to get the authentication credentials for the URL’s hostname from the user’s netrc file. The netrc file overrides raw HTTP authentication headers set with headers.

Source: https://docs.python-requests.org/en/latest/user/authenticati...


I know, I took a look at the code.

I even replaced get_openai_key(params) with a hardcoded

  return "sk-redacted"
and still no luck. I guess the bug must be in the openai python package, but I cant find it either. However, rest assured I am not providing this email anywhere manually...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: