HTTP 'Content-Type' Header is not allowed

hey, i’m extremely new to HTTP stuff and i needed an AI chatbot for my game (i chose DialoGPT from Hugging Face, as it’s free to use), when i make a request it says
image
can someone help me fix this?

--// Hugging Face setup
local url = "https://api-inference.huggingface.co/models/microsoft/DialoGPT-small"
local headers = {
	["Authorization"] = "my-token", -- cannot share the token obviously
	["Content-Type"] = "application/json"
}

--// Sequence
while true do
	task.wait(3)
	Sounds.Bell:Play()
	task.wait(0.2)
	tweenIn:Play()
	task.wait(1)

	local product = products[math.random(1, #products)]
	local messagePicked = beginnings[math.random(1, #beginnings)]
	local textAsked = string.gsub(messagePicked, "<PRODUCT>", product)

	dialogueRF:InvokeClient(player, textAsked)

	local pitch = player.Chatted:Wait()

	-- Build prompt for DialoGPT
	local prompt = "The player is trying to sell you an item called '" .. product .. "'. They say: " .. pitch .. " What is your response?"

	-- Send to Hugging Face API
	local body = HTTPService:JSONEncode({
		inputs = prompt
	})

	local success, response = pcall(function()
		return HTTPService:PostAsync(url, body, Enum.HttpContentType.ApplicationJson, false, headers)
	end)

	if success then
		local result = HTTPService:JSONDecode(response)
		local message = result[1] and result[1].generated_text or "Sorry, what?"

		dialogueRF:InvokeClient(player, message)
	else
		warn("Error talking to DialoGPT:", response)
		dialogueRF:InvokeClient(player, "uhh... mhgg.... let me sleep on it..")
	end
end

this feature is required for my game, so i would deeply appreciate any help!

Did you set that fixed status? Didn’t even know that was possible here.

no, its not visible to me? this isnt even a bug report, weird

Oh ok, if you view a bug report with a status I guess that status just persists to the next topic(s).

1 Like

bump, cant continue development on the game without this feature!

I Am Also pretty new to httpService but i dont think you need to specify Content-Type in the header as you are already specifying it when sending the request, maybe try removing the Content-Type key from the header and try again, if not i have no idea

thanks, chatgpt wrote the http part since im new, so ill try that tommorrow.

this worked, but now i’m getting the HTTP 403 (Forbidden) error.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.