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.
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:
ub_live_…— production, billed against your prepaid credit.ub_test_…— free, rate-limited, for local development.
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.
| Model | Alias points to | Context | Best for |
|---|---|---|---|
| unbleep | unbleep-250811 | 128K | General use — the default |
| unbleep-code | unbleep-code-250811 | 128K | Code & security research |
Chat completions
POST /v1/chat/completions — the core endpoint. Request and response bodies match the OpenAI schema.
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
}'
{
"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].
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.
off— unfiltered baseline (default). No refusals injected.research— logs and tags sensitive categories for audit, still answers.strict— applies your configured blocklist and returns a policy error on a match.
{
"model": "unbleep",
"messages": […],
"policy": "research"
}
Errors
Errors use the OpenAI envelope, so existing error handling works unchanged.
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key",
"message": "Incorrect API key provided."
}
}
| Status | Meaning |
|---|---|
| 401 | Missing or invalid key |
| 402 | Out of credit — top up to continue |
| 422 | Blocked by policy: strict |
| 429 | Rate limit — back off and retry |
| 5xx | Upstream error — safe to retry with backoff |
Rate limits
Every response carries the standard headers so you can pace requests without guessing:
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.