API reference

unbleep speaks the OpenAI Chat Completions API. If you've called OpenAI before, you already know this API — point your client at https://api.unbleep.ai/v1 and change the key.

Quickstart

Install the OpenAI SDK, set the base URL and your key, and make a call.

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.unbleep.ai/v1",
    api_key="ub_live_9f2c…",
)

resp = client.chat.completions.create(
    model="unbleep",
    messages=[{"role": "user", "content": "Say hello."}],
)
print(resp.choices[0].message.content)

Authentication

Every request needs a Bearer token in the Authorization header. Keys carry a prefix so a leak is obvious to secret scanners:

header
Authorization: Bearer ub_live_9f2c…

Keep keys server-side. Never ship a live key in browser or mobile code.

Models

Pass one of these IDs as model. The bare alias always points to the latest build; pin a dated snapshot for reproducibility.

ModelAlias points toContextBest for
unbleepunbleep-250811128KGeneral use — the default
unbleep-codeunbleep-code-250811128KCode & security research

Chat completions

POST /v1/chat/completions — the core endpoint. Request and response bodies match the OpenAI schema.

curl · request
curl https://api.unbleep.ai/v1/chat/completions \
  -H "Authorization: Bearer ub_live_9f2c…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "unbleep",
    "messages": [
      {"role": "system", "content": "You are terse."},
      {"role": "user", "content": "Explain abliteration in one line."}
    ],
    "temperature": 0.7,
    "max_tokens": 256
  }'
json · response
{
  "id": "chatcmpl_a1b2c3",
  "object": "chat.completion",
  "model": "unbleep-250811",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "…" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 24, "completion_tokens": 18, "total_tokens": 42 }
}

Streaming

Set "stream": true to receive Server-Sent Events. Each event is a chat.completion.chunk with a delta; the stream ends with a literal data: [DONE].

event stream
data: {"choices":[{"delta":{"content":"Ab"}}]}
data: {"choices":[{"delta":{"content":"literation"}}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}]}
data: [DONE]

Policy dial

unbleep's differentiator. The optional policy parameter sets how much governance runs on a request. It defaults to off.

json · request fragment
{
  "model": "unbleep",
  "messages": [],
  "policy": "research"
}

Errors

Errors use the OpenAI envelope, so existing error handling works unchanged.

json · 401
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_api_key",
    "message": "Incorrect API key provided."
  }
}
StatusMeaning
401Missing or invalid key
402Out of credit — top up to continue
422Blocked by policy: strict
429Rate limit — back off and retry
5xxUpstream error — safe to retry with backoff

Rate limits

Every response carries the standard headers so you can pace requests without guessing:

response headers
x-ratelimit-limit-requests: 600
x-ratelimit-remaining-requests: 598
x-ratelimit-reset-requests: 1s

Test keys are capped low; live keys scale with your prepaid balance. Need more headroom? Enterprise lifts the ceiling.