I shared in the past something very similar using openai, the difference is that its possible to use Gemini Pro for free (max 60 time per minute i think, but that is good enough= and its very easy to get the api key.
Just go to
https://makersuite.google.com/app/apikey
and easily create you free apikey.
I just started using it, but in my opinion (just test it a few times) its better than openai. It can also write some code...
Code: Select all
Procedure.s SendPrompt(sPrompt.s)
sUrl.s = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY"
NewMap Header$()
Header$("content-type") = "application/json"
sBody.s = "{"
sBody.s + Chr(34) + "contents" + Chr(34) + ": ["
sBody.s + "{"
sBody.s + Chr(34) + "parts" + Chr(34) + ": ["
sBody.s + "{"
sBody.s + Chr(34) + "text" + Chr(34) + ": " + Chr(34) + sPrompt + Chr(34)
sBody.s + "}]"
sBody.s + "}]"
sBody.s + "}"
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$ = "Write an article about Purebasic"
SendPrompt(lKeyword$)