Integrations

Uncensored AI for Unity Games

Send OpenAI-compatible chat completions from Unity with UnityWebRequest.

Updated 2025-12-31

Use UnityWebRequest to post a chat completion with your abliteration.ai API key.

using System.Collections;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;

public class AblitExample : MonoBehaviour {
  [SerializeField] private string apiKey;

  public IEnumerator Send() {
    var payload = "{\"model\":\"abliterated-model\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello from Unity.\"}]}";
    var req = new UnityWebRequest("https://api.abliteration.ai/v1/chat/completions", "POST");
    req.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(payload));
    req.downloadHandler = new DownloadHandlerBuffer();
    req.SetRequestHeader("Authorization", "Bearer " + apiKey);
    req.SetRequestHeader("Content-Type", "application/json");
    yield return req.SendWebRequest();
    Debug.Log(req.downloadHandler.text);
  }
}