uncensored
v0.1.0-alpha.1
Published
Official TypeScript / JavaScript SDK for Uncensored.com — uncensored AI chat completions, image generation, video generation, and prompt enhancement. Drop-in OpenAI-compatible chat API.
Maintainers
Keywords
Readme
uncensored — Official TypeScript SDK for Uncensored.com
Official TypeScript / JavaScript SDK for the Uncensored.com Developers API — uncensored AI chat completions (drop-in OpenAI-compatible), image generation, video generation, face swap, image editing, and prompt enhancement.
0.1.0-alpha.1 — hand-written alpha. Surface may change before 1.0.
Install
npm install uncensoredRequires Node.js 18+ (uses global fetch, AbortController, Web Streams, FormData). Strict-typed (no any in public surface). Dual ESM / CJS. Zero runtime dependencies.
Also available as the alias package uncensored-ai.
Authentication
import Uncensored from "uncensored";
const client = new Uncensored({
apiKey: process.env.UNCENSORED_API_KEY,
});You can also set UNCENSORED_API_KEY (and optionally UNCENSORED_BASE_URL) and call new Uncensored() with no arguments.
Chat completion
const completion = await client.chat.completions.create({
model: "model_t_2",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello!" },
],
});
console.log(completion.choices[0].message.content);Streaming chat
const stream = await client.chat.completions.create({
model: "model_t_2",
messages: [{ role: "user", content: "Write a haiku." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta.content ?? "");
}Cancel a stream:
stream.controller.abort();Image generation
const result = await client.images.generate({
prompt: "A cyberpunk skyline at dusk",
model: "model-pro",
wait: true,
});
console.log(result);For async-only flow, omit wait and poll client.images.retrieve(jobId) or use client.images.waitForCompletion(jobId).
Per-request options
await client.images.generate(
{ prompt: "..." },
{ idempotencyKey: "my-key", timeout: 30_000, signal: ac.signal },
);Errors
import {
AuthenticationError,
InsufficientFundsError,
RateLimitError,
} from "uncensored";
try {
await client.chat.completions.create({ /* ... */ });
} catch (err) {
if (err instanceof RateLimitError) { /* back off */ }
}Reference
See the full API reference at https://docs.uncensored.com for the complete list of endpoints, request/response shapes, and webhook payloads.
