Documentation

Liberty Jail API

An OpenAI- and Anthropic-compatible API for abliterated open-weight models. If your code already talks to one of those two APIs, you only change the base URL, the key and the model id.

Quickstart

  1. Create an account and add credit from Console → Billing (crypto, minimum $10).
  2. Open Console → API keys and create a key. Copy it right away — the full key is only shown once.
  3. Export it as an environment variable and send your first request:
export LJ_API_KEY="lj_..."

curl {{BASE}}/chat/completions \
  -H "Authorization: Bearer $LJ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "{{MODEL}}",
    "messages": [{"role": "user", "content": "Explain what a Kerberoasting attack is in three sentences."}]
  }'
# pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="{{BASE}}", api_key=os.environ["LJ_API_KEY"])

resp = client.chat.completions.create(
    model="{{MODEL}}",
    messages=[{"role": "user", "content": "Explain what a Kerberoasting attack is in three sentences."}],
)
print(resp.choices[0].message.content)
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "{{BASE}}", apiKey: process.env.LJ_API_KEY });

const resp = await client.chat.completions.create({
  model: "{{MODEL}}",
  messages: [{ role: "user", content: "Explain what a Kerberoasting attack is in three sentences." }],
});
console.log(resp.choices[0].message.content);

Authentication

Every request needs an API key. Keys start with lj_ and can be sent in either of two headers — use whichever your client already sets:

HeaderFormatTypical client
AuthorizationBearer lj_…OpenAI SDKs, curl, most tools
x-api-keylj_…Anthropic SDKs
Treat keys like passwords. Keep them server-side, never in a browser bundle or a public repo. If one leaks, revoke it in Console → API keys; it stops working immediately.

Base URLs

FormatBase URLEndpoints
OpenAI/chat/completions, /models
Anthropic/v1/messages

The Anthropic SDKs add /v1/messages themselves, so give them the host without /v1. OpenAI SDKs expect the URL with /v1.

Models

GET/models

Lists the model ids your key can call, in the usual OpenAI list format.

curl {{BASE}}/models -H "Authorization: Bearer $LJ_API_KEY"
{
  "object": "list",
  "data": [
    { "id": "{{MODEL}}", "object": "model" }
  ]
}

Current catalogue (live):

Model idContextMax outputInput / 1MOutput / 1MInput types
Loading…

Rows marked “coming soon” on the models page are listed but return 404 until they go live.

Chat Completions

POST/chat/completions

OpenAI-format chat endpoint. Send a list of messages, get the next assistant message back.

Request body

FieldTypeDescription
modelstringRequired. A model id, e.g. .
messagesarrayRequired. Objects with role (system, user, assistant) and content.
max_tokensintegerUpper limit on generated tokens. Capped by the model’s max output.
temperaturenumberSampling temperature, usually 0–2. Lower is more deterministic.
top_pnumberNucleus sampling, 0–1.
stopstring | arraySequences where generation stops.
streambooleanSend the answer as server-sent events while it is generated.
stream_optionsobject{"include_usage": true} adds a final chunk with token counts.

Response

{
  "id": "chatcmpl-8f2c...",
  "object": "chat.completion",
  "model": "{{MODEL}}",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Kerberoasting abuses service tickets..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 21, "completion_tokens": 96, "total_tokens": 117 }
}

Streaming

Set "stream": true. You receive data: {...} lines, each carrying a piece of text in choices[0].delta.content, then data: [DONE]. With stream_options.include_usage, the last chunk before [DONE] has an empty choices array and a usage object.

stream = client.chat.completions.create(
    model="{{MODEL}}",
    messages=[{"role": "user", "content": "Write a Sigma rule for suspicious certutil downloads."}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        print("\n", chunk.usage)
const stream = await client.chat.completions.create({
  model: "{{MODEL}}",
  messages: [{ role: "user", content: "Write a Sigma rule for suspicious certutil downloads." }],
  stream: true,
  stream_options: { include_usage: true },
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
  if (chunk.usage) console.log("\n", chunk.usage);
}
data: {"id":"chatcmpl-8f2c","choices":[{"index":0,"delta":{"content":"title: "}}]}

data: {"id":"chatcmpl-8f2c","choices":[{"index":0,"delta":{"content":"Certutil"}}]}

data: {"id":"chatcmpl-8f2c","choices":[],"usage":{"prompt_tokens":18,"completion_tokens":240,"total_tokens":258}}

data: [DONE]

Messages (Anthropic format)

POST/v1/messages

The same models, exposed in the Anthropic Messages format, so the Anthropic SDKs and tools built on them work unchanged. max_tokens is required here, and the system prompt goes in the top-level system field. Streaming uses "stream": true and the Anthropic event types.

# pip install anthropic
import os
import anthropic

client = anthropic.Anthropic(base_url="{{ABASE}}", api_key=os.environ["LJ_API_KEY"])

msg = client.messages.create(
    model="{{MODEL}}",
    max_tokens=1024,
    system="You are a senior incident responder.",
    messages=[{"role": "user", "content": "Triage these Windows event IDs: 4624, 4672, 4688."}],
)
print(msg.content[0].text)
curl {{ABASE}}/v1/messages \
  -H "x-api-key: $LJ_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "{{MODEL}}",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Triage these Windows event IDs: 4624, 4672, 4688."}]
  }'

Image input

Models whose input types include image (see the table above) accept pictures — screenshots, diagrams, photos of a screen. In the OpenAI format, make content an array of parts and add an image_url part. A base64 data: URL is the most reliable option.

import base64

with open("phishing.png", "rb") as f:
    b64 = base64.b64encode(f.read()).decode()

resp = client.chat.completions.create(
    model="{{MODEL}}",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Is this login page a phishing kit? List the tells."},
            {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
        ],
    }],
)

Sending an image to a text-only model returns an error. Images count toward input tokens.

Errors

Errors use the OpenAI shape on every endpoint: an HTTP status plus a JSON body with a readable message, a type and a code.

{
  "error": {
    "message": "Your balance is too low for this request. Top up in the console.",
    "type": "insufficient_quota",
    "code": "insufficient_balance"
  }
}
StatusMeaningWhat to do
401Missing, wrong, revoked or expired keyCheck the header and the key status in the Console.
402Balance empty, or the key’s budget is used upTop up, or raise the key’s daily/total budget.
404Unknown model id, or a model that isn’t live yetCall GET /v1/models for valid ids.
429Too many requests, or too many at onceWait and retry with exponential backoff.
502The upstream model server failedRetry after a short pause.

Rate limits

LimitDefaultScope
Requests per minute60per API key
Concurrent requests8per account (all keys together)

Going over either limit returns 429. Your current limits are on Console → Limits. If you need more headroom, message us on Telegram.

Billing

  • Prepaid. You hold a balance in US dollars. Top it up with crypto from Console → Billing (minimum $10). It is credited automatically once the payment confirms.
  • Per token. Each request costs its tokens multiplied by the model’s price per million tokens — input, output and cached input are priced separately. Cached input is the cheapest of the three.
  • No subscription. Nothing renews; when the balance reaches zero, requests return 402 until you top up.
Example. 2,000 input tokens and 500 output tokens on a model priced $1.50 / $3.00 per million cost 2,000 × 1.50 / 1,000,000 + 500 × 3.00 / 1,000,000 = $0.0045.

Every request, with its tokens and cost, is listed in Console → Activity and can be exported as CSV. Prices for each model are on the pricing page.

Key budgets & expiry

Give each project, teammate or customer its own key, and cap it:

SettingEffect
Total budgetLifetime dollar cap for this key. Once reached, the key returns 402.
Daily budgetDollar cap per day. Requests resume the next day.
Expiry dateAfter this date the key returns 401.
RevokeDisables the key immediately and for good.

Budgets and the expiry date can be changed at any time from Console → API keys. Leave a field empty for “no limit”. Spending is always bounded by your account balance as well.

SDK examples

Complete, copy-paste examples for the common clients. Replace the model id with any id from the catalogue.

curl {{BASE}}/chat/completions \
  -H "Authorization: Bearer $LJ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "{{MODEL}}",
    "messages": [
      {"role": "system", "content": "You are a penetration tester writing a report."},
      {"role": "user", "content": "Summarise the impact of an exposed .git folder."}
    ],
    "max_tokens": 800,
    "temperature": 0.4
  }'
# pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="{{BASE}}", api_key=os.environ["LJ_API_KEY"])

resp = client.chat.completions.create(
    model="{{MODEL}}",
    messages=[
        {"role": "system", "content": "You are a penetration tester writing a report."},
        {"role": "user", "content": "Summarise the impact of an exposed .git folder."},
    ],
    max_tokens=800,
    temperature=0.4,
)
print(resp.choices[0].message.content)
print(resp.usage)
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "{{BASE}}",
  apiKey: process.env.LJ_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "{{MODEL}}",
  messages: [
    { role: "system", content: "You are a penetration tester writing a report." },
    { role: "user", content: "Summarise the impact of an exposed .git folder." },
  ],
  max_tokens: 800,
  temperature: 0.4,
});
console.log(resp.choices[0].message.content);
# pip install anthropic
import os
import anthropic

client = anthropic.Anthropic(base_url="{{ABASE}}", api_key=os.environ["LJ_API_KEY"])

with client.messages.stream(
    model="{{MODEL}}",
    max_tokens=800,
    system="You are a penetration tester writing a report.",
    messages=[{"role": "user", "content": "Summarise the impact of an exposed .git folder."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Questions or something not working? Reach us on Telegram.