EN ▾

unrestrictedaimodel.topuncensored2026-10-08

Uncensored LLM API for Developers

Unrestricted AI Model API: JSON Mode Setup

To get JSON from an unrestricted ai model api json style request, set response_format to json_object, point the OpenAI SDK at the base URL and use the model ID uncensored. The steps, code and failure handling are below.

Terminal feeding structured data blocks through a glowing prism into a crate, illustrating JSON output from an API

No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).

Get API key

The minimal working request

You need three things: your key, the base URL https://api.unrestrictedaimodel.top/v1 and the model ID uncensored. JSON mode is switched on with one parameter, response_format, set to {"type": "json_object"}. Here it is with curl:

curl https://api.unrestrictedaimodel.top/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "response_format": {"type": "json_object"},
    "messages": [
      {"role": "system", "content": "Reply with a JSON object only."},
      {"role": "user", "content": "Give a name, a role and a one-line backstory for a tavern keeper in a fantasy novel. Use the keys name, role and backstory."}
    ]
  }'

The reply arrives in choices[0].message.content as a string that you then parse. Note that the string is still text until you call a JSON parser. JSON mode makes a valid object far more likely, but your code should not assume it.

The same call with the OpenAI Python SDK

The service is OpenAI-compatible, so the official SDK works after you change the base URL and key. This example asks for structured data, parses it and fails loudly if a field is missing.

import json
from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedaimodel.top/v1",
    api_key="YOUR_API_KEY",
)

resp = client.chat.completions.create(
    model="uncensored",
    response_format={"type": "json_object"},
    temperature=0.7,
    messages=[
        {
            "role": "system",
            "content": 'Reply with one JSON object with keys "name" (string), "role" (string) and "backstory" (string). No other text.',
        },
        {"role": "user", "content": "A tavern keeper for a gritty fantasy novel."},
    ],
)

choice = resp.choices[0]
if choice.finish_reason == "length":
    raise RuntimeError("Reply was cut off, so the JSON is incomplete")

data = json.loads(choice.message.content)
for key in ("name", "role", "backstory"):
    if key not in data:
        raise ValueError("Missing key: " + key)
print(data)

Two habits are worth copying. First, spell out the keys and their types in the system prompt rather than only asking for "JSON". Second, treat the parsed object as untrusted input and check it before it reaches your database or UI.

The same call in Node

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.unrestrictedaimodel.top/v1",
  apiKey: process.env.API_KEY,
});

const resp = await client.chat.completions.create({
  model: "uncensored",
  response_format: { type: "json_object" },
  messages: [
    { role: "system", content: "Reply with a JSON object with keys title and tags (array of strings)." },
    { role: "user", content: "Suggest a title and three tags for a noir detective story." },
  ],
});

const choice = resp.choices[0];
if (choice.finish_reason === "length") throw new Error("Truncated reply");
const data = JSON.parse(choice.message.content);
console.log(data);

The response object has the same shape as the Python one, so choices[0].message.content holds the JSON text and usage reports token counts you can log. Keep the key in an environment variable, not in source code. Browser code should not hold the key at all, so call the API from a server and expose only your own endpoint to the front end.

Why replies can still break

JSON mode reduces broken output, but a few failure modes remain. Know them before you ship.

  • Truncation. If the reply stops at a token limit, you receive half an object. Check finish_reason. The parameter max_tokens is optional on this API, so only set it if you want a cap, and make it comfortably larger than the biggest object you expect. The context window is 100,000 tokens for prompt and completion together.
  • Wrong shape. Valid JSON can still have missing keys, extra keys or wrong types. Validate after parsing.
  • Prompt drift. A long conversation can bury the formatting instruction. Repeat the key list in the final user message when you reuse a long history.
  • High temperature. Creative sampling can produce odd values. For extraction or classification, use a low temperature, such as 0 to 0.3. The seed parameter is passed through if you want repeatable runs.
  • Fences and prose. Some replies wrap output in extra text. Strip it only as a fallback, and log how often it happens.

A simple retry loop covers most of this: parse, validate, and on failure resend once with a short note listing what was wrong. Cap the number of attempts at two or three, because each retry is billed like any other successful call.

Tool calling as a stricter alternative

When you need a precise structure, such as arguments for a function, tool calling is often a better fit than free-form JSON mode. You pass a list of tools with a JSON schema for the parameters, optionally set tool_choice, and the model returns tool_calls with the arguments as a JSON string. Results go back as messages with role: "tool". Streamed responses include streamed tool_calls as well.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedaimodel.top/v1",
    api_key="YOUR_API_KEY",
)

tools = [{
    "type": "function",
    "function": {
        "name": "save_character",
        "description": "Store a character sheet",
        "parameters": {
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "age": {"type": "integer"},
                "traits": {"type": "array", "items": {"type": "string"}},
            },
            "required": ["name", "age"],
        },
    },
}]

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Create a weary ship captain, age 52."}],
    tools=tools,
    tool_choice="auto",
)
print(resp.choices[0].message.tool_calls)

Use JSON mode for documents and reports, and tool calling when the output feeds straight into code. Either way, validate the result yourself.

Prompt patterns that produce stable JSON

The prompt does most of the work, so write it like a small contract. Name every key, give each a type, and say what to do when information is missing. A good rule is to ask for null rather than allow invention, and to list allowed values for any field that should be an enum.

  • State the shape once, clearly. A line such as: keys are "name" (string), "level" (integer from 1 to 10) and "tags" (array of strings, may be empty).
  • Constrain choices. For a category field, list the exact allowed strings and tell the model to pick one.
  • Show one example. A single short sample object in the system prompt anchors the format better than a paragraph of description.
  • Keep creative text inside string fields. If you want a story plus metadata, put the story in a "text" key rather than asking for prose followed by JSON.
  • Ask for one object. A top-level object is easier to handle than a bare array, so wrap lists in a key such as "items".

Test the prompt on a dozen varied inputs, including empty or odd ones, before you trust it with a batch.

It also helps to separate extraction from generation. When the model must read a document and report facts, use a low temperature and tell it to quote only what the text says. When it must invent, such as characters, items or dialogue for a game, raise the temperature and validate only the shape. Mixing both goals in one call is the most common reason a pipeline works on ten samples and fails on a thousand. Store the raw reply next to the parsed object for the first few runs so you can see what the model actually returned when a field looks wrong, and keep the prompt text in version control alongside the code that reads its output.

A wrapper with validation and retries

Once the basic call works, wrap it so every caller gets the same behavior. The function below parses the reply, checks required keys, retries once with feedback if the check fails, and backs off on HTTP 429.

import json
import time
from openai import OpenAI, RateLimitError

client = OpenAI(
    base_url="https://api.unrestrictedaimodel.top/v1",
    api_key="YOUR_API_KEY",
)

def ask_json(prompt, required, attempts=3):
    messages = [
        {"role": "system", "content": "Reply with one JSON object only."},
        {"role": "user", "content": prompt},
    ]
    for attempt in range(attempts):
        try:
            resp = client.chat.completions.create(
                model="uncensored",
                response_format={"type": "json_object"},
                temperature=0.2,
                messages=messages,
            )
        except RateLimitError:
            time.sleep(5)
            continue
        choice = resp.choices[0]
        text = choice.message.content
        try:
            data = json.loads(text)
            missing = [k for k in required if k not in data]
            if not missing and choice.finish_reason == "stop":
                return data
            note = "Missing keys: " + ", ".join(missing)
        except json.JSONDecodeError:
            note = "That was not valid JSON."
        messages.append({"role": "assistant", "content": text})
        messages.append({"role": "user", "content": note + " Try again."})
    raise RuntimeError("No valid JSON after retries")

The five-second sleep matches the Retry-After: 5 header the API sends on temporary overload. For heavy batches, run a small worker pool capped below 8 so you stay inside the concurrency limit of a full key.

Streaming, limits and cost

You can combine JSON mode with stream: true, but you must collect all chunks before parsing, because a partial object is not valid JSON. Streaming responses send usage at the end. A streamed request keeps its concurrency slot until the stream finishes.

A full key allows 8 concurrent requests and 300 requests per minute, and a trial key allows 2 and 60. Over a limit you get HTTP 429 with the code rate_limited (requests per minute) or concurrency (too many at once). A temporary overload also returns 429 with a Retry-After: 5 header, so wait that long before retrying. The maximum body is 8 MB.

Structured output is cheap. A job with 800 input tokens and 300 output tokens costs 800 x $0.15 / 1M = $0.00012 for input, plus 300 x $0.50 / 1M = $0.00015 for output, which is $0.00027. A batch of 1,000 such records costs $0.27, and failed or refused requests are not charged. The rate is $0.15 per 1M input and $0.50 per 1M output tokens from prepaid credit.

Get a key and test it

Sign up with Google, or with email and password, and claim the trial: $0.50 of credit with one click on the API key page. It is valid for 7 days, needs no card and is one per person. That is enough for roughly 1,800 of the structured jobs above ($0.50 / $0.00027 is about 1,851).

From there, the quickstart covers the base URL and basic calls, and the pricing page lists top-up options, starting at $20. If a request fails and you cannot see why, the troubleshooting guide lists common causes. The model is text only, so image, audio and embedding output are outside what this API does, and our one fixed content rule is that sexual content involving minors is never allowed.

Questions and answers

How do I turn on JSON mode?

Add response_format with {"type": "json_object"} to your POST /v1/chat/completions request. Also describe the keys you want in the prompt.

Is the reply guaranteed to be valid JSON?

No. Always parse inside a try block and check finish_reason, because a reply cut off by a token limit will be incomplete.

Which model ID should I use?

Use uncensored, with the base URL https://api.unrestrictedaimodel.top/v1 and a Bearer key.

Can I stream JSON output?

Yes, with stream set to true, but you need to join all the chunks before parsing.

Should I use JSON mode or tool calling?

Use JSON mode for free-form structured documents and tool calling when you want arguments that match a schema and feed straight into code.

Your key is one form away

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

Get API key