EN ▾
Get API key

ChatGPT API for Developers: Use the OpenAI SDK

You do not need a new SDK or a new mental model to try an uncensored text model. The request and response shapes are the ones you already know from the OpenAI client libraries, so the work is mostly configuration.

Updated

A glass terminal sending streams of glowing blocks to a server, illustrating an OpenAI-compatible API call

Key points

  1. Set base_url to https://api.unrestrictedchatgpt.cc/v1, use your key as the bearer token, and send model uncensored.
  2. Streaming, tool calling, JSON mode and the usual sampling parameters work through the standard client.
  3. Handle HTTP 429 by reading the error code and waiting; an overload response carries Retry-After: 5.
  4. Text only: chat completions and a model list, with no embeddings, images or fine-tuning.

What you are connecting to

If you are searching for the chatgpt api for developers, you probably want the familiar chat completions interface: send a list of messages, get a reply, optionally stream it, optionally let the model call your functions. This service offers exactly that interface. It exposes POST /v1/chat/completions and GET /v1/models, accepts Authorization: Bearer YOUR_KEY, and answers in the OpenAI response format. The difference is the model behind it.

That model is a single open-weight model, named uncensored in requests, run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not the official API of OpenAI or of any other vendor, and it is not a router across several. Because the protocol matches, any library that lets you override the base URL will work.

Get a key and set up the environment

Sign up with Google or with email and password, open the key page, and create your key. Right after sign-up you can claim $0.50 of trial credit with one click, with no card, valid for 7 days. Trial keys are limited to 2 concurrent requests and 60 requests per minute, which is plenty for development. The API key page walks through the steps.

Keep the key out of source control. Put it in an environment variable and read it at start-up:

export UNRESTRICTED_KEY="YOUR_KEY"
# base URL: https://api.unrestrictedchatgpt.cc/v1   model: uncensored
pip install openai
# or: npm install openai
curl https://api.unrestrictedchatgpt.cc/v1/models -H "Authorization: Bearer $UNRESTRICTED_KEY"

The last line is a quick connectivity check. A JSON list that includes uncensored means the key and URL are right.

Your first request in Python and Node

With the official Python package, only the constructor differs from a stock setup:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedchatgpt.cc/v1",
    api_key=os.environ["UNRESTRICTED_KEY"],
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "You write terse, vivid scene descriptions."},
        {"role": "user", "content": "Describe an abandoned subway platform at 3 a.m."},
    ],
    temperature=0.9,
    max_tokens=300,
)
print(resp.choices[0].message.content)
print(resp.usage)

The Node version looks almost identical:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.unrestrictedchatgpt.cc/v1",
  apiKey: process.env.UNRESTRICTED_KEY,
});

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Give me three names for a ghost ship." }],
});
console.log(resp.choices[0].message.content);

Setting max_tokens is optional. If you leave it out, the completion can use the rest of the 100,000-token window, which is shared between prompt and reply. For chat UIs, a cap such as 500 or 800 keeps replies from running on.

Migrating code you already have

If a project already calls the OpenAI SDK in twenty places, you do not need to touch each call. The official Python and Node clients read the OPENAI_BASE_URL and OPENAI_API_KEY environment variables when you create a client without arguments. Set them for the process and the existing code starts talking to the new endpoint:

export OPENAI_BASE_URL="https://api.unrestrictedchatgpt.cc/v1"
export OPENAI_API_KEY="YOUR_KEY"
curl "$OPENAI_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"ping"}],"max_tokens":5}'

The only edit left is the model string. Search your code for hard-coded model names and move them to one config value, so you can switch between providers per feature. Frameworks that wrap the SDK, such as LangChain-style libraries or chat front ends, usually expose the same two settings under names like "API base" and "API key". Paste the same values there.

Check anything that depends on features outside the chat interface. Calls to embeddings, moderation, image generation or fine-tuning endpoints will not find a match on this service, and your error handling should make that obvious instead of silently falling back.

Prompting an open-weight model

Prompts written for one model transfer well to another, but a few habits pay off here. Put the role and the output format in the system message and keep it short. Give the model the facts it needs inside the prompt instead of relying on memory, because an open-weight model of this kind can state details with confidence and still get them wrong. For anything factual, supply the source text and ask for answers drawn from it.

Sampling matters more than people expect. For fiction and roleplay, a temperature between 0.8 and 1.0 with top_p around 0.95 gives varied prose. For extraction and classification, drop the temperature to 0 or near it and set seed so repeated runs match as closely as possible. The penalty parameters are passed through, so a small frequency penalty can stop long outputs from looping on one phrase. Add stop sequences when you template multi-speaker dialogue, so the model does not write the other party's lines.

Finally, keep history under control. The window is 100,000 tokens, but a chat that sends everything every turn spends input tokens on text that no longer matters. Summarize older turns into one short message once the history passes a size you choose.

Streaming, tool calling and JSON mode

Streaming

Streaming uses server-sent events, enabled with stream: true. Token usage is reported at the end of the stream, which is convenient for billing logs.

from openai import OpenAI

client = OpenAI(base_url="https://api.unrestrictedchatgpt.cc/v1", api_key="YOUR_KEY")

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Write a limerick about a stubborn compiler."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

One operational detail matters here. A streamed request holds its concurrency slot until the stream finishes. If your front end opens a stream and the user walks away, close the connection on your side, or the slot stays busy and you may see a 429 with the code concurrency on the next request.

Tool calling and JSON mode

Function calling follows the standard shape. You pass tools, optionally tool_choice, read tool_calls from the reply, run the function yourself, and send the result back as a message with role: "tool".

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.unrestrictedchatgpt.cc/v1", api_key="YOUR_KEY")

tools = [{
    "type": "function",
    "function": {
        "name": "roll_dice",
        "description": "Roll a die with the given number of sides",
        "parameters": {
            "type": "object",
            "properties": {"sides": {"type": "integer"}},
            "required": ["sides"],
        },
    },
}]

messages = [{"role": "user", "content": "Roll a twenty-sided die for the goblin's attack."}]
first = client.chat.completions.create(model="uncensored", messages=messages, tools=tools)
call = first.choices[0].message.tool_calls[0]
args = json.loads(call.function.arguments)

messages.append(first.choices[0].message)
messages.append({"role": "tool", "tool_call_id": call.id, "content": "14"})
final = client.chat.completions.create(model="uncensored", messages=messages, tools=tools)
print(final.choices[0].message.content)

For structured output, set response_format={"type": "json_object"} and say in the system message which keys you expect. Validate the result in your code anyway; JSON mode asks for valid JSON, and it does not enforce your own schema. Open-weight models also do better when you show one short example of the target object.

Limits, errors and retries

A full key allows 8 concurrent requests and 300 requests per minute. Bodies can be up to 8 MB. Every response carries X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, so log them. When you go over a limit the API returns HTTP 429 with the error code rate_limited (too many requests per minute) or concurrency (too many at once). Temporary overload also returns 429, with Retry-After: 5.

The right reaction differs. For concurrency, add a semaphore in your client so no more than 8 requests are in flight. For rate_limited, spread calls out. For the overload case, wait the advertised five seconds and try again.

import time
from openai import OpenAI, RateLimitError

client = OpenAI(base_url="https://api.unrestrictedchatgpt.cc/v1", api_key="YOUR_KEY", max_retries=0)

def ask(prompt, tries=4):
    for attempt in range(tries):
        try:
            r = client.chat.completions.create(
                model="uncensored",
                messages=[{"role": "user", "content": prompt}],
            )
            return r.choices[0].message.content
        except RateLimitError as e:
            wait = int(e.response.headers.get("retry-after", 5))
            time.sleep(wait * (attempt + 1))
    raise RuntimeError("still rate limited after retries")

Failed or refused requests are not charged, so retrying does not cost you for the failed attempt.

Production checklist and boundaries

A short production checklist

  • Put the key in a secret store, never in browser code. Call the API from your server.
  • Cap concurrency in your client at 8 for a full key, or 2 for a trial key.
  • Set a client timeout that suits long completions, and close streams when the user disconnects.
  • Log X-Request-Id with every call so a bad response can be traced when you contact support.
  • Read X-Balance-USD and alert when credit gets low, since the service is prepaid.
  • Validate every JSON reply before using it, even in JSON mode.
  • Keep your own content rules for your own users. The model's flexibility does not replace product policy.

What to plan around

A few boundaries are worth knowing before you commit. The service is text only: there are no image, audio or video outputs, no embeddings and no fine-tuning. If your architecture needs a vector store, produce embeddings from another source and keep this endpoint for generation. The hard content limit is that nothing sexual involving minors is allowed, and the service is for lawful adult use. Prompts are not used for training.

On cost, the rates are $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit with no subscription. A $20 minimum top-up buys a lot of development time. Bonuses of 5%, 10% and 15% apply from $50, $100 and $200, and you can pay by by crypto. See the pricing page for the full table and the docs for the reference. If you are comparing this against your current provider for a specific project, the page on the uncensored API explains where it fits and where it does not.

Questions and answers

Is this the official ChatGPT API?

No. It is an independent service with an OpenAI-compatible interface and its own open-weight model. It is not operated by OpenAI.

Which model name do I use?

Use uncensored as the model value. You can confirm it by calling GET /v1/models.

Does the OpenAI SDK need patching?

No. Set the base URL and API key in the client constructor. Streaming, tool calling and JSON mode go through the normal methods.

What happens when I hit a rate limit?

You receive HTTP 429 with the code rate_limited or concurrency. If the cause is temporary overload, the response includes Retry-After: 5.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Start with trial credit

Email and password, key on screen right away.