Jump to content

How can I make http request in a mod?

Recommended Posts

I'm trying to use ChatGPT in my mod to plan behaviours of an AI character, which requires sending request to openai.com. However the lua environment doesn't have `socket` library. From a previous post (https://forums.kleientertainment.com/forums/topic/58269-thenet-and-establishing-connections/) it seems it's not allowed to make http request in the mod, but I'm not sure. Is it possible to install the socket library in the environment, or are there other available libraries to send requests? Or are there any other workarounds?


Link to comment
Share on other sites

You can make requests using:

TheSim:QueryServer(url [, callbackfn [, method [, encoded_data [, timeout]]]])

But this does only support GET and POST request methods and you can only modify the body of the request not the headers or anything else.

So for authorization in the Open AI API you will have to use some kind of a proxy server.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...