5 ms·
can you try: curl https://api.openai.com/v1/completions https://api.openai.com/v1/completions -H "Content-Type: application/json" -H "Authorization: Bearer
by ramblerman 4y ago
can you try:
curl https://api.openai.com/v1/completions 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
}'
- lynx23 4y agoYes, 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.
- ramblerman 4y agoIts 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/4ce28739ca7ada161102917ad256d3db61026392/chatblade/cli.py#L17 https://github.com/npiv/chatblade/blob/4ce28739ca7ada1611029...
- lynx23 4y agoI 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...
- lynx23 4y agoFound 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.
- matzf 4y agoThe 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/authentication/#netrc-authentication https://docs.python-requests.org/en/latest/user/authenticati...