What do you want to achieve? I am trying to access the ChatGPT API just for experimental purposes of communicating with an AI from a Roblox game, ask it questions and stuff.
What is the issue? I’m not sure how to really do that… This is my current code, but I’m getting an error:
local HTTPService = game:GetService("HttpService")
local API_Key = "not-sharing-my-key"
local URL = "https://api.openai.com/v1/completions/"..API_Key
local Data = {
["model"] = "text-davinci-003",
["prompt"] = "Say this is a test",
["temperature"] = 0,
["max_tokens"] = 7
}
HTTPService:GetAsync(URL) -- Line the error occurs on.
Edit: I also looked in their API docs but only Python code snippets were provided and Python has way different syntax and possibilities than Luau so I wasn’t able to make anything from it.
You need to POST, not GET. Your setup is also wrong–you need to provide headers for your API key and not put at the end of the URL. Your data is also unused.
this is amazing. Do you perhaps have a tiny tutorial, or a step by step guide how to start? Where to use the code, how to run it and how to setup a everything from the start till the GUI, including prompting with chatGPT?
I’m unable to really test that because I don’t have any OpenAI credit but all you really have to do is listen to a remote function from the client, add some sort of rate limiting and using their prompts that you received from the remote function to call the API.