Integrations

Uncensored LLM for iOS

Use URLSession in Swift to call the OpenAI-compatible /v1/chat/completions endpoint.

Updated 2026-08-04

Send a POST request from Swift with URLSession and your abliteration.ai API key.

import Foundation

let url = URL(string: "https://api.abliteration.ai/v1/chat/completions")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(ProcessInfo.processInfo.environment[\"ABLIT_KEY\"] ?? \"\")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let payload: [String: Any] = [
  "model": "abliterated-model",
  "messages": [
    ["role": "user", "content": "Hello from Swift."]
  ]
]

request.httpBody = try JSONSerialization.data(withJSONObject: payload)

URLSession.shared.dataTask(with: request) { data, _, _ in
  if let data = data {
    print(String(data: data, encoding: .utf8) ?? "")
  }
}.resume()
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.