MINEOGO

You don't have to see this

Jan 10th, 2025 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. local function requestRoast(prompt)
  2. -- Define the payload
  3. local payload = {
  4. userMessage = {
  5. role = "user",
  6. content = prompt
  7. },
  8. history = {
  9. {
  10. role = "assistant",
  11. content = "Hello there. I'm here to roast you."
  12. }
  13. },
  14. style = "default"
  15. }
  16.  
  17. -- Convert the payload to JSON
  18. local json = game:GetService("HttpService"):JSONEncode(payload)
  19.  
  20. -- Perform the API request
  21. local response = http_request({
  22. Url = "https://www.roastedby.ai/api/generate",
  23. Method = "POST",
  24. Headers = {
  25. ["Accept"] = "*/*",
  26. ["Accept-Language"] = "en-US,en;q=0.9",
  27. ["Content-Type"] = "application/json"
  28. },
  29. Body = json
  30. })
  31.  
  32. -- Check response and parse it
  33. if response and response.StatusCode == 200 then
  34. local data = game:GetService("HttpService"):JSONDecode(response.Body)
  35. return data.content or "No response from the API."
  36. else
  37. return "Request failed: " .. (response and response.StatusMessage or "Unknown error")
  38. end
  39. end
  40.  
  41. -- Example usage
  42. local roast = requestRoast("Why do programmers prefer dark mode?")
  43. print(roast)
Advertisement
Add Comment
Please, Sign In to add comment