#API isn't responding
27 messages · Page 1 of 1 (latest)
This API endpoint doesn't exist
and then you'd pass the model, in your case, text-davinci-003 as a param named model in the POST req
Appreciate for comments. @warm ivy @prisma meteor I edited that way, however, I got this error. I copied and pasted my API key so my API key is not wrong. https://beta.openai.com/account/api-keys it says API keys have never been used. Am I putting request in a wrong way?
You really should delete your photo @candid mason
For obvious reasons
Also, you're not putting in the API key correctly
Why are you using requests? OpenAI has a python module to do all the heavy lifting for you
Lastly, exposing your API key in your JavaScript file is a surefire way to get yourself banned, or maxed out
Please, I'm not being over the top. Do not ever put your API key somewhere that can be read. It's like taping your key to the front door
Change the JS code to send a request to a backend server such as Flask. Get rid of your python code as well, use the OpenAI module "import openai". You can then set your key properly with openai.api_key = ""
If you are hellbent on using requests - there's no immediate benefits but whatever, you need to include the API key in your header, not in the JSON data
Python code
import openai
openai.api_key = "sp-TCCYbWOYsENTERYOUKEYFJcADpWRhkMPDkfpeca1xv"
def talk_with_model(prompt, filter_level=None):
if filter_level == "off":
prompt = "filter=off" + prompt
elif filter_level == "low":
prompt = "filter=low" + prompt
completions = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
max_tokens=2048,
n=1,
stop=None,
temperature=0.5,
)
message = completions.choices[0].text
return message.strip()
while True:
user_input = input("You: ")
if user_input == "exit":
break
elif user_input == "vulgar":
filter_level = "off"
elif user_input == "clean":
filter_level = "low"
else:
filter_level = None
response = talk_with_model(user_input, filter_level)
print("ChatGPT: ",response)
For the love of security can y'all stop posting your API keys
what key?
Your key is in the code @warm ivy
No its not look and you can see i removed a part and typed in uppercase ENTERYOURKEY
im silly but not that silly
But i like to thank you for warning people to not be so careless, you are truly a good human being.
@candid mason I’ve deleted your image that had an API key in it
@warm ivy thank you for the kind words