Integrations

Uncensored AI for Unity Games

Send OpenAI-compatible chat completions from Unity with UnityWebRequest.

Updated 2026-08-04

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);
  }
}
FAQ

Frequently asked questions.

How do I fix a 401 Unauthorized error from abliteration.ai?

Check that your API key is set and sent as a Bearer token.

How do I fix a 404 Not Found error from abliteration.ai?

Make sure the base URL ends with /v1 and you call /chat/completions.

How do I fix a 400 Bad Request error from abliteration.ai?

Verify the model id and that messages are an array of { role, content } objects.

How do I fix a 429 Rate limit error from abliteration.ai?

Back off and retry. Use the Retry-After header for pacing.