Re: Openai (ChatGPT) from PB
Posted: Mon Aug 28, 2023 5:14 pm
Try to create an APIkey with a free account, I think in the past it was possible (don't know actually).
http://www.purebasic.com
https://www.purebasic.fr/english/
Yoiu are welcome!!jak64 wrote: Mon Aug 28, 2023 12:14 pm Thanks for the info Ricardo.
Have a nice day (even if the Argentinian beat France at football, I'm French)![]()
}Fig wrote: Tue Nov 14, 2023 9:22 pm Hi,
I tried it...
How long does it take to get an answer ?
It very very slow... more than 10 minutes !!
Can we get the answer letter by letter like in chatgpt instead of the whole long one ?
Code: Select all
sModel.s = "gpt-3.5-turbo-1106"
Code: Select all
sModel = "dall-e-3"
Code: Select all
Procedure.s SendPrompt(sPrompt.s)
sUrl.s = "https://api.openai.com/v1/images/generations"
NewMap Header$()
Header$("content-type") = "application/json"
Header$("Authorization") = "Bearer YOURAPIKEY "
nMaxTokens.l = 5000
sModel.s = "dall-e-3"
sNumberOfResponses = 1
sTemperature.f = 0.9
sBody.s = "{"
sBody.s = sBody.s + Chr(34) + "model" + Chr(34) + ": " + Chr(34) + sModel + Chr(34) + ", "
sBody + Chr(34) + "prompt" + Chr(34) + ": " + Chr(34) + sPrompt + Chr(34) + ", "
sBody.s + Chr(34) + "n" + Chr(34) + ": " + Str(sNumberOfResponses) + ", "
sBody + Chr(34) + "quality" + Chr(34) + ": " + Chr(34) + "hd" + Chr(34) + ", "
sBody + Chr(34) + "size" + Chr(34) + ": " + Chr(34) + "1024x1024" + Chr(34)
sBody.s + "}"
; Debug sBody
Define httpReq
httpReq = HTTPRequest(#PB_HTTP_Post, sUrl, sBody, 0, Header$())
If httpReq
Response$ = Trim(HTTPInfo(httpReq, #PB_HTTP_Response))
Debug Response$
EndIf
EndProcedure
lKeyword$= "Create and hipperrealistic image of a cat in the floor of a beautiful kitchen drinking milk in the sunsent hour HD"
SendPrompt(lKeyword$)