Stable Diffusion API: Prompts and scripts over one endpoint
Generate uncensored prompts and scripts for your Stable Diffusion or video workflows using a single OpenAI-compatible endpoint. Get started with a quick API key and a simple text request.
Base URL
https://api.sdxlapi.com/v1Modeluncensored
Base URL & Authentication
Access the API using the base URL https://api.sdxlapi.com/v1. This endpoint is fully compatible with standard OpenAI SDKs and clients. To authenticate, pass your API key in the Authorization header of every request.
How to get a key: Sign up at the Get API key page with just an email and password. Your key is displayed immediately. No credit card is required for the trial. Keep your key secure; you can regenerate it anytime, which invalidates the old one.
First Request
Send a standard chat-completions request to generate text. The model ID is uncensored. This model is tuned to answer without content refusals for lawful adult use, making it ideal for creative prompt generation.
curl https://api.sdxlapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
}'The API accepts JSON payloads with a messages array. It returns a text completion. You can pass system prompts to define the persona, such as a professional prompt engineer for image generation.
Python SDK Integration
Use the official openai Python package. Configure the client with the base URL and your API key. This approach works for any OpenAI-compatible client.
from openai import OpenAI
client = OpenAI(base_url="https://api.sdxlapi.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)The response contains the generated text in response.choices[0].message.content. You can parse this output directly into your pipeline for captions or metadata extraction. The SDK handles JSON serialization and HTTP details automatically.
Node SDK Integration
For JavaScript or TypeScript projects, use the openai npm package. Set the baseURL and apiKey in the configuration object. This ensures compatibility with existing OpenAI codebases.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.sdxlapi.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);The response structure mirrors the standard OpenAI format. Access the generated text via response.data.choices[0].message.content. This is useful for server-side prompt generation before sending images to a Stable Diffusion instance.
Streaming Responses
Support for Server-Sent Events (SSE) allows you to receive tokens as they are generated. This reduces perceived latency for long prompt scripts or detailed descriptions.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Stream the response in your client application. Each chunk contains a partial message. Aggregate these chunks to reconstruct the final text. This is especially useful for real-time preview of generated prompts in a web interface.
Limits, Errors & Context
Rate Limits: 300 requests per minute per key. Body Size: Max 8 MB. Context Window: 100,000 tokens total (input + output). This allows for long scripts or extensive prompt engineering.
Common Errors:
401 Unauthorized:Invalid or missing API key.402 Payment Required:Insufficient prepaid credit.429 Too Many Requests:Rate limit exceeded.
If you exceed limits, wait briefly or regenerate your key. All requests are text-only; no images, audio, or video are generated by this API.
API specifications
If your tool speaks the OpenAI API, these are the details that matter.
| Parameter | Details |
|---|---|
| Compatibility | OpenAI Chat Completions schema; official openai SDKs work unchanged |
| Model | uncensored |
| Base URL | https://api.sdxlapi.com/v1 |
| API key | Bearer token in the Authorization header |
| Methods | POST /v1/chat/completions · GET /v1/models |
| Function calling | Supported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages |
| Completion length | 16,000 tokens max; 2,048 if max_tokens is not set |
| SSE streaming | Yes — server-sent events; the last chunk carries token usage |
| Sampling parameters | temperature, top_p, stop, seed, presence_penalty, frequency_penalty |
| Context window | 100,000 tokens, input and output combined |
| Structured output | response_format: {"type": "json_object"} |
| Request size | 8 MB request body |
| Parallel requests | 8 requests at the same time per key |
| Rate limit | 300/min per key |
| Headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Token prices | input $0.25 / 1M tokens, output $1.00 / 1M tokens |
| Credit expiry | paid credit never expires, no subscription |
| How you pay | pay as you go from prepaid credit; nothing is charged for failed or refused requests |
| Volume bonus | +5% from $50, +10% from $100 |
| Top-up | USDT (TRC20) or USDC (Base), any whole amount from $10 to $500 |
| Free trial | $0.50 for 7 days, no card |
| Content policy | uncensored for adults; the only hard rule: no sexual content involving minors |
| Key management | one active key per account; a new key replaces the old one |
| Account | sign in with Google or with e-mail + password |
Error codes
The type field is stable, the message is for humans. Errors cost nothing.
| HTTP | Type | What to do |
|---|---|---|
400 | bad_request | malformed request or too long for the context window |
401 | missing_key · invalid_key · key_revoked | no key, wrong key, or a key replaced by a newer one |
402 | no_credit | balance is empty — top up, requests resume at once |
403 | content_blocked | refused by the content policy |
404 | not_found | only /v1/chat/completions and /v1/models exist |
413 | request_too_large | body over 8 MB |
429 | rate_limited · concurrency | slow down: rate or parallel limit reached |
503 | upstream_busy | model busy — retry in a few seconds |
Questions and answers
Is this the official Stable Diffusion image generation API?
No. This is a text-only LLM API. It powers the prompt generation and post-processing steps for your Stable Diffusion pipeline. It does not generate images, audio, or video itself.
What happens if I exceed my rate limit?
You will receive a 429 status code. The limit is 300 requests per minute per key. You can regenerate your key at any time, which revokes the old one and resets your quota.
Is the API truly uncensored?
Yes, for lawful adult use. The model does not refuse controversial, adult, or security-research topics. It only blocks sexual content involving minors. It is not GPT, Claude, or any other vendor's model.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.