PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → request openIA
request openIA
Iniciado por rafael tapia, 17,abr. 2023 18:02 - No hay respuesta
Publicado el 17,abril 2023 - 18:02
Hola Amigos, como codificarían en WEBDEV el llamado a la api de openIA ?

la especificacion dada por openIA es:

curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Say this is a test!"}],
"temperature": 0.7
}'

en webDev yo codifique asi: (pero no me funciona)

gcRequest is httpRequest
gcResponse is httpResponse

// Arma, envia y recibe
gcRequest..URL = "https://api.openai.com/v1/chat/completions/"
gcRequest..ContentType = typeMimeJSON
gcRequest..Method = httpGet
gcRequest..Content = sPide

gcRequest..Header["Authorization"] = "sk-XXXXX-XXXXX-XXXXX_XXXXX"
gcRequest..Header["OpenAI-Organization"] = "rtSoftware" // "org-ojpfP6TqLFBCF8LLZV1atBQH" //= "rtSoftware"

gcResponse = HTTPSend(gcRequest)
IF ErrorOccurred THEN
Info(" ERROR:",ErrorInfo())
ELSE
Info(" Respuesta:",gcResponse..Content)
END

me responde que no estoy enviando correctamente la APIKEY que es es la que coloco en Header["Authorization"]

"message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY)f or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": null
>


Gracias !