Integrations

Uncensored AI for Java

Send OpenAI-compatible chat completions from Java using java.net.http.HttpClient.

Updated 2026-08-04

Use Java HttpClient to post a chat completion request to abliteration.ai.

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class AblitExample {
  public static void main(String[] args) throws Exception {
    String apiKey = System.getenv("ABLIT_KEY");
    String body = "{\"model\":\"abliterated-model\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello from Java.\"}]}";

    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.abliteration.ai/v1/chat/completions"))
      .header("Authorization", "Bearer " + apiKey)
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(body))
      .build();

    HttpClient client = HttpClient.newHttpClient();
    HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
  }
}
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.