Hi,
Does anyone have any clue on how to connect to the API from openAI? I have tried very hard but getting 401 back every time.
Maybe someone can share their setup on this? Thank you very much!
THis my last try with it.
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer API_KEY"
}
data = {
"prompt": "Schrijf een kort verhaal over een eenzame astronaut die in de ruimte ronddrijft.",
"temperature": 0.5,
"max_tokens": 100,
"n": 1,
"stop": None
}
response = requests.post(url, headers=headers, json=data)
print(response.json()['choices'][0]['text'])
Does anyone have any clue on how to connect to the API from openAI? I have tried very hard but getting 401 back every time.
Maybe someone can share their setup on this? Thank you very much!
THis my last try with it.
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer API_KEY"
}
data = {
"prompt": "Schrijf een kort verhaal over een eenzame astronaut die in de ruimte ronddrijft.",
"temperature": 0.5,
"max_tokens": 100,
"n": 1,
"stop": None
}
response = requests.post(url, headers=headers, json=data)
print(response.json()['choices'][0]['text'])