nsfwapis.com
// Guide / Guides

How to switch to an OpenAI compatible uncensored API

An OpenAI compatible uncensored API accepts the same requests as the OpenAI API, so you can move an app to it by changing three values: the base URL, the API key and the model ID. 4 of the 5 text providers in this directory work this way, and 4 also accept the Anthropic format. This guide shows the switch in Python and JavaScript, what else can differ, and the errors you are most likely to hit.

What is an OpenAI compatible uncensored API?

It is an API that serves uncensored or abliterated models behind the same HTTP interface that OpenAI uses. You send a POST request to /chat/completions with a model and a list of messages, and you get back a choices array and a usage object in the same shape OpenAI returns.

Because the format matches, the official OpenAI SDKs, and most tools built on them, can talk to the provider without code changes. The SDK doesn’t care who runs the server. It joins the base URL you give it with the endpoint path, adds your key as a bearer token and parses the JSON that comes back.

Two things stay different. The provider hosts its own models, so the model IDs are new, and the models themselves behave differently: they are open-weight models such as GLM and DeepSeek that have been fine-tuned or abliterated so they refuse far less. The uncensored LLM guide explains how those models are made.

The word “uncensored” is about the model, not the API. The API is just plumbing. Whether a request is answered depends on the model you pick and the provider’s terms.

Which uncensored APIs are OpenAI compatible?

Refuseless, Unaligned, UncensoredLLM and NanoGPT list OpenAI-compatible endpoints. Refuseless, Unaligned, UncensoredLLM and NanoGPT also accept the Anthropic message format. Uncensored.com uses its own variant of chat completions.

API format, base URL and payment for each uncensored text API in the directory
ProviderAPI formatBase URLPayment
RefuselessOpenAI and Anthropichttps://api.refuseless.com/v1Card or crypto
UnalignedOpenAI and AnthropicIn the provider’s quickstartCrypto only
Uncensored.comChat completions with X-Api-Key headerhttps://api.uncensored.com/api/v1Card
UncensoredLLMOpenAI and Anthropichttps://api.uncensoredllm.ai/v1Card or crypto
NanoGPTOpenAI and Anthropichttps://api.nano-gpt.com/api/v1Card or crypto

Base URLs are taken from each provider’s profile and were last checked on 2026-11-12. Confirm them in the provider’s quickstart before you deploy, since a wrong path is the most common setup error. Uncensored.com needs one extra step, covered in the JavaScript section below.

How to use an uncensored API with the OpenAI Python SDK

Pass a different base_url and api_key when you create the client, then use the provider’s model ID. Nothing else in a basic chat call changes.

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ["LLM_BASE_URL"],  # the provider's base URL, including /v1
    api_key=os.environ["LLM_API_KEY"],
)

reply = client.chat.completions.create(
    model=os.environ["LLM_MODEL"],  # the exact ID from the provider's model list
    messages=[
        {"role": "system", "content": "You are a fiction co-writer."},
        {"role": "user", "content": "Continue the scene from where we stopped."},
    ],
    max_tokens=400,
)

print(reply.choices[0].message.content)
print(reply.usage)  # prompt_tokens and completion_tokens, for cost tracking

Keeping the three values in environment variables has a practical benefit: you can point the same code at a second provider, or back at a mainstream model, without a deploy. The OpenAI SDKs also read OPENAI_BASE_URL and OPENAI_API_KEY on their own, so if your existing code builds a client with no arguments, setting those two variables is enough to redirect it.

To find valid model IDs, call client.models.list(). Most OpenAI-compatible providers implement GET /models, and the IDs it returns are the strings to pass as model. Display names on a pricing page, like GLM-5.3 Flash Uncensored, are often formatted differently from the ID. UncensoredLLM’s own setup steps, for example, use the ID glm-5.3-uncensored.

How to switch in JavaScript and Node.js

The official openai package for Node.js takes the same two options, named baseURL and apiKey:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: process.env.LLM_BASE_URL,
  apiKey: process.env.LLM_API_KEY,
});

const stream = await client.chat.completions.create({
  model: process.env.LLM_MODEL,
  messages: [{ role: "user", content: "Write the opening line of the story." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Streaming uses server-sent events in the same format as OpenAI, so chat front ends that already stream token by token keep working. Note the optional chaining on choices[0]: some providers send a final chunk with an empty choices array that carries only usage data.

Keep API keys on the server. Calling a provider straight from browser code exposes the key to every visitor, and with a prepaid balance that means anyone can spend it.

Custom key headers. Uncensored.com lists its format as “Chat completions with X-Api-Key header”. The request body is the same, but the key goes in a different header. Both SDKs accept extra headers, so you can still use them:

const client = new OpenAI({
  baseURL: process.env.LLM_BASE_URL,
  apiKey: "unused",  // the SDK requires a value
  defaultHeaders: { "X-Api-Key": process.env.LLM_API_KEY },
});

In Python the option is default_headers. The SDK still sends an Authorization header with the placeholder, which a provider that reads X-Api-Key should ignore. Check that in a first test call.

Using the Anthropic format instead

If your code or tool was written for Claude, Refuseless, Unaligned, UncensoredLLM and NanoGPT accept the Anthropic message format as well, so you can keep the Anthropic SDK. The change is the same idea: a new base URL, your provider key and the provider’s model ID.

import os
from anthropic import Anthropic

client = Anthropic(
    base_url=os.environ["LLM_ANTHROPIC_BASE_URL"],
    api_key=os.environ["LLM_API_KEY"],
)

msg = client.messages.create(
    model=os.environ["LLM_MODEL"],
    max_tokens=400,  # required in this format
    system="You are a fiction co-writer.",
    messages=[{"role": "user", "content": "Continue the scene."}],
)

print(msg.content[0].text)

The two formats differ in ways that matter when you port code between them:

Main differences between the OpenAI and Anthropic request formats
DetailOpenAI formatAnthropic format
Endpoint path/chat/completions/v1/messages
System promptA message with role systemA top-level system field
Max outputmax_tokens is optionalmax_tokens is required
Reply textchoices[0].message.contentcontent[0].text
Token countsprompt_tokens, completion_tokensinput_tokens, output_tokens

Watch the base URL. The Anthropic SDK adds /v1/messages itself, so the Anthropic base URL a provider gives you often has no /v1 at the end, while its OpenAI base URL does. Use the exact value from the provider’s quickstart for each format. Coding tools that speak the Anthropic format can also be pointed at these providers. UncensoredLLM lists Claude Code among the clients it works with.

What else changes when you switch?

For plain chat, usually nothing. The differences show up in the features around the core call. “Compatible” means the provider accepts the same request shape, not that it supports every parameter OpenAI does.

  • Model IDs. Every provider names models its own way, and some rename or retire them. Pin the exact ID and keep it in config.
  • Tool calling and JSON output. The tools and response_format parameters depend on the model and on the provider’s server. A server can also ignore a parameter it doesn’t support without returning an error, which is harder to spot. Test them with a model you plan to use.
  • Newer OpenAI endpoints. Compatible providers mostly implement chat completions. If your code uses OpenAI’s newer Responses API, assistants or file endpoints, check whether the provider supports them, or port that code to chat completions.
  • Streaming usage. How and whether token counts arrive in a stream differs between servers. If you bill users from usage, confirm you receive it when stream is on.
  • Moderation. If your app called OpenAI’s moderation endpoint, that call doesn’t move with the switch. Decide what checks you still need and run them yourself.
  • Context and limits. Context windows, max output and rate limits are set per model and per provider. Read them on the model list, not from the OpenAI defaults in your code.

The first requests after a switch tend to fail in a few predictable ways:

Common errors after switching to an OpenAI-compatible API and how to fix them
ErrorUsual causeFix
401 UnauthorizedWrong key, or the key in the wrong headerCheck the key and whether the provider wants a bearer token or a custom header
404 Not FoundBase URL missing /v1, or /v1 added twiceUse the base URL exactly as the provider documents it
404 or 400 on the modelDisplay name used instead of the model IDCopy the ID from GET /models
400 Bad RequestA parameter the provider doesn’t acceptRemove optional parameters one at a time to find it
Payment or balance errorPrepaid balance is emptyTop up, and alert on low balance before it runs out
429 Too Many RequestsProvider rate limitRetry with backoff and cap concurrent requests

How much does the switch cost?

All the uncensored text APIs here are prepaid and billed per token, so you can price the move before you write any code. Take a chat app that sends 100,000 requests a month, each about 1,000 input and 250 output tokens. On each provider’s example model, the published rates give:

Monthly cost of 100,000 requests at 1,000 input and 250 output tokens, from published rates
Provider and modelInput / output per 1MPer 1,000 requestsPer month
UnalignedGLM-5.3 Flash Uncensored$0.063 / $0.10$0.088$8.80
UncensoredLLMGLM-5.3 Flash Uncensored$0.105 / $0.368$0.197$19.74
RefuselessDeepSeek V4.1 Flash 1017 Abliterated$0.12 / $0.45$0.233$23.25
NanoGPTGLM 5.3 Flash Uncensored$0.20 / $0.80$0.40$40.00
Uncensored.comGLM-5.3 Flash Cyber Uncensored$0.96 / $1.92$1.44$144.00

That puts the same workload between $8.80 a month on Unaligned and $144.00 on Uncensored.com. The example models aren’t equal in size or quality, so treat the table as a first filter. Chat apps that re-send long histories are much more input-heavy than this example. The pricing comparison guide covers that case and cached input.

Since the code is the same for every compatible provider, a cheap way to choose is to run your real prompts through two or three of them with only the environment variables changed, then compare the usage numbers and the replies side by side.

Migration checklist

  1. Move the three values into config. Base URL, key and model ID, read from environment variables.
  2. List the models. Call GET /models and copy the exact IDs you want.
  3. Send one plain request. No tools, no JSON mode, no streaming. Fix auth and path errors here.
  4. Add features one at a time. Streaming, then tools or JSON output, then anything else your app uses.
  5. Log usage. Store prompt_tokens and completion_tokens per request and compare them with your balance after a day.
  6. Run your own test prompts. 20 to 50 real prompts, including ones a mainstream model refuses and normal ones. Judge quality as well as refusals.
  7. Read the provider’s terms. Check its acceptable-use rules and how it handles logs for your use case. Content that is illegal, including any sexual content involving minors and intimate images of real people made without consent, stays illegal on every model.
  8. Keep a fallback. With the same code on every provider, a second provider is one config change away if a model is retired.

Frequently asked questions

Is there an uncensored OpenAI API?

OpenAI itself doesn’t offer uncensored models. Several third-party providers serve uncensored and abliterated open-weight models behind an OpenAI-compatible API, so the OpenAI SDK works with them after you change the base URL, the key and the model ID.

Can I use the OpenAI SDK with an uncensored API?

Yes, if the provider is OpenAI-compatible. Refuseless, Unaligned, UncensoredLLM and NanoGPT are, according to their directory listings. Create the client with the provider’s base URL and your key, and pass the provider’s model ID.

Is there an uncensored ChatGPT API?

Not from OpenAI. ChatGPT models follow OpenAI’s usage policies. If you want ChatGPT-style requests with fewer refusals, use an OpenAI-compatible provider that hosts uncensored open-weight models such as GLM or DeepSeek builds.

Why do I get a 404 after changing the base URL?

Usually the path is wrong. The OpenAI SDK adds /chat/completions to the base URL, so the base URL must end where the provider says, often with /v1. A missing or doubled /v1, or a display name used as the model ID, are the common causes.

Can I use an OpenAI compatible LLM API with the Anthropic SDK?

Only if the provider also implements the Anthropic format. Refuseless, Unaligned, UncensoredLLM and NanoGPT do. Use the provider’s Anthropic base URL, which often differs from its OpenAI one.

Prices and offers come from each provider’s published information, checked . They can change, so confirm them on the provider’s site. Found something out of date? Tell us.