OpenAI Wrapper (ChatGPT)

OpenAI FiveM Wrapper

OpenAI FiveM Wrapper allows you to interact with the OpenAI API

How to install

  1. Download the resource from the GitHub page
  2. Get your OpenAI API Key from here
  3. Add a convar in your server.cfg as follow: set openai_api_key yourApiKey
  4. Add ensure openai_fivem to your server.cfg
  5. Restart your server
  6. You’re done ! You can start using the OpenAI FiveM Wrapper

How to use

1 - Chat Completion

Create chat completion using OpenAI GPT models

Prototype:
doChatCompletion(message, [optionnal] systemOrder, [optionnal] model)
Examples:
local number <const> = exports.openai_fivem:doChatCompletion("Give me a number between 1 and 5")
local answer <const> = exports.openai_fivem:doChatCompletion("Give me my money!!", "You are a police officer NPC in a video game", "gpt-4")

Possible issues

For the moment, OpenAI handles each request individually, so you cannot make several requests at once. Use the isBusy export to knows if you can make a request.

Need support ?

You can directly reply to this post or DM me.

5 Likes

Eemmmhh, I did not really understand what does this script do?

3 Likes

It allows you to interact with OpenAI’s API.
If you knows ChatGPT, you can ask ChatGPT directly from your fivem script.

1 Like

I was getting ready to go through dozens of pages of their docs to get this to work. Thank you so much. There’s a lot of stuff we’re gonna be able to do with this.

1 Like