Migrate from the OpenAI API
To switch an existing OpenAI chat completions integration to an uncensored model, change three values: the base URL, the API key and the model id. The rest of your code stays the same.
The three changes
| Setting | Before | After |
|---|---|---|
| Base URL | https://api.openai.com/v1 | https://API_HOST/v1 |
| API key | OpenAI key | Uncensored Inference key |
| Model | An OpenAI model name | The id from GET /models |
With environment variables only
The official SDKs read these variables, so many applications migrate without a code change:
export OPENAI_BASE_URL="https://API_HOST/v1"
export OPENAI_API_KEY="your-uncensored-inference-key"
In code
import os
from openai import OpenAI
client = OpenAI(
base_url="https://API_HOST/v1",
api_key=os.environ["UI_API_KEY"],
)
reply = client.chat.completions.create(
model="MODEL_ID", # listed by client.models.list()
messages=[{"role": "user", "content": "Summarise the scope document below."}],
)
print(reply.choices[0].message.content)
What stays the same
- The
/chat/completionsrequest and response format. - Streaming with server-sent events.
- Tool calls in the
toolsformat. - Error format and HTTP status codes.
What differs
- Endpoints. Only chat completions and models. No embeddings, images, audio, files, assistants or fine-tuning.
- Model behaviour. The model does not refuse by reflex and adds fewer warnings. Remove jailbreak-style prompt workarounds; plain instructions work better.
- Tokenizer. Token counts differ from OpenAI models for the same text. Use the
usagefield returned by the API. - Context. 245,760 tokens shared between input and output.
- Moderation. There is no moderation endpoint and no content filter. Your application decides what to do with the output.
Frameworks and tools
Any tool with an "OpenAI-compatible" or "custom base URL" setting works the same way: enter the base URL, the key and the model id.
Frequently asked questions
How do I switch from the OpenAI API to an uncensored model?
Change the base URL to the uncensored provider's endpoint, use the key it issued and set the model id it lists. With an OpenAI-compatible API such as Uncensored Inference, the rest of the code is unchanged.
Do OpenAI SDKs work with Uncensored Inference?
Yes. Set OPENAI_BASE_URL and OPENAI_API_KEY, or pass base_url and api_key when creating the client.
Last updated: 2 December 2026