Post request to GPT-3 API

bhtvdmeer

Client
Регистрация
20.02.2022
Сообщения
6
Благодарностей
0
Баллы
1
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'])
 

Besedi

Client
Регистрация
04.03.2019
Сообщения
234
Благодарностей
40
Баллы
28
Use openai lib
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)