Key points
- Any OpenAI SDK works after you change two values: the base URL and the key.
- The model ID is uncensored, and the endpoints are POST /v1/chat/completions and GET /v1/models.
- Streaming, tool calling and JSON mode use the same parameters you already know.
- Handle HTTP 429 with a short wait, and watch the concurrency slot on streamed requests.
What "using the GPT API" means in practice
People who ask how to use gpt api usually want one of two things. Either they want OpenAI's own service, or they want the request style that service made popular: a JSON body with a model and a list of messages, a bearer key in the header, and a reply that carries choices and usage. The second thing is a format, and many providers now speak it. If your code already uses an OpenAI SDK, you can point it somewhere else by changing a base URL.
That is what this site offers. It is a hosted API for one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not GPT, and it is not a router that forwards your call to other vendors. You send the same kind of request, and the model that answers is the one behind the model ID uncensored. For the official OpenAI service you need an account with OpenAI and its own documentation; this article covers only our endpoint.
Two endpoints are available: POST /v1/chat/completions for generation and GET /v1/models to list what your key can call. Everything else in the OpenAI surface, such as images, audio, embeddings and fine-tuning, is not offered here. The service is text only.
Get a key and check the connection
Sign up with Google, or with an email and a password. On the API key page you can claim $0.50 of trial credit with one click. It is one per person, it needs no payment, and it stays valid for 7 days. That is enough for a few hundred test calls, as the numbers further down show. The full steps are on the API key page.
Store the key in an environment variable instead of pasting it into source files. On macOS or Linux that is export API_KEY=... in your shell. Then check the connection with the models endpoint. If the call returns a JSON list that includes uncensored, your key and your network path both work.
curl https://api.unrestrictedgrok.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Say hello in five words."}]
}'
curl https://api.unrestrictedgrok.com/v1/models -H "Authorization: Bearer $API_KEY"The first curl call sends a chat request. The second lists models. Both use the header Authorization: Bearer followed by your key. If you get HTTP 401, the key is wrong or has a stray space. If you get a connection error, check that the base URL ends in /v1 and has no trailing path after it.
Python with the openai package
Install the official package with pip install openai. The only differences from a standard OpenAI script are the base_url argument and the model name.
from openai import OpenAI
client = OpenAI(
base_url="https://api.unrestrictedgrok.com/v1",
api_key="YOUR_API_KEY",
)
reply = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain what a base URL is in two sentences."},
],
temperature=0.7,
)
print(reply.choices[0].message.content)
print(reply.usage.prompt_tokens, reply.usage.completion_tokens)Read the usage object after each call. It gives prompt and completion token counts, which you can turn into cost: input tokens cost $0.15 per million and output tokens cost $0.50 per million. A reply with 1,000 prompt tokens and 500 completion tokens costs 1,000 x $0.15 / 1,000,000 + 500 x $0.50 / 1,000,000, which is $0.00015 + $0.00025 = $0.0004. The response headers also carry X-Balance-USD, so you can see the remaining credit without a separate call. More on rates is on the pricing page.
Parameters such as temperature, top_p, stop, seed and the frequency and presence penalties are passed through. max_tokens is optional. If you leave it out, the reply can use whatever is left of the 100,000-token window, which covers prompt and completion together.
Node.js and other clients
The JavaScript package is openai on npm. Set baseURL in the constructor and everything else stays the same.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.unrestrictedgrok.com/v1",
apiKey: process.env.API_KEY,
});
const reply = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "List three uses of a system prompt." }],
});
console.log(reply.choices[0].message.content);The same idea applies to any tool that lets you enter a custom OpenAI endpoint. Chat front ends, notebook plugins and agent frameworks usually expose two fields: a base URL and an API key. Fill in https://api.unrestrictedgrok.com/v1 and your key, then type uncensored where the model name goes. If a client insists on a dropdown of known GPT names, look for a custom or other option, or use the models endpoint to confirm the ID you should type. The quickstart lists the settings in one place.
Streaming, JSON mode and tool calls
Streaming
Set stream: true and the server sends chunks over SSE. Ask for usage at the end with stream_options so you still get token counts. One detail matters for capacity: a streamed request keeps its concurrency slot until the stream ends, so a client that opens a stream and never reads it will block a slot.
from openai import OpenAI
client = OpenAI(base_url="https://api.unrestrictedgrok.com/v1", api_key="YOUR_API_KEY")
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a four-line poem about a build server."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print("\n", chunk.usage.prompt_tokens, chunk.usage.completion_tokens)JSON mode
Pass response_format with type json_object and say in the system prompt which keys you want. The reply will be a JSON object you can parse. Still wrap json.loads in a try block, and keep a fallback for the rare malformed answer.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.unrestrictedgrok.com/v1", api_key="YOUR_API_KEY")
r = 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."},
{"role": "user", "content": "Describe a short story about a lighthouse keeper."},
],
)
data = json.loads(r.choices[0].message.content)
print(data["title"], data["tags"])Tool calling
Tools work as in the OpenAI format: you send tools and optionally tool_choice, the model returns tool_calls, you run the function yourself, and you send the result back as a message with role: "tool". Streamed tool calls are supported too. The model only decides which function to call; your code does the work.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.unrestrictedgrok.com/v1", api_key="YOUR_API_KEY")
tools = [{
"type": "function",
"function": {
"name": "get_time",
"description": "Return the current time for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
messages = [{"role": "user", "content": "What time is it in Lisbon?"}]
first = client.chat.completions.create(model="uncensored", messages=messages, tools=tools, tool_choice="auto")
msg = first.choices[0].message
if msg.tool_calls:
call = msg.tool_calls[0]
args = json.loads(call.function.arguments)
result = {"city": args["city"], "time": "14:05"} # your real lookup goes here
messages.append(msg)
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
final = client.chat.completions.create(model="uncensored", messages=messages, tools=tools)
print(final.choices[0].message.content)Prompt and sampling habits that save tokens
Once the connection works, most of your cost and quality comes from how you build the messages array. Keep the system message short and specific: say what role the model plays, what format the answer takes and what to avoid. A system prompt of 150 tokens repeated over 10,000 calls is 1.5 million input tokens, which is $0.225 at $0.15 per million. That is small, but a 3,000-token system prompt repeated the same way is 30 million tokens and $4.50, so trim anything that does not change the answer.
For factual or structured work, lower the temperature to around 0.2 and set a fixed seed so reruns are easier to compare. For fiction or brainstorming, 0.8 to 1.0 gives more variety. If a reply repeats phrases, raise the frequency penalty a little rather than rewriting the prompt. Use stop sequences when you only need the text up to a marker.
Conversation history is the other cost driver. Every turn resends the earlier turns, so a long chat grows the input each time. Summarize old turns once they pass a few thousand tokens, or drop the ones that no longer matter. Because the window is 100,000 tokens, you have room, but you pay for every input token on every call.
Limits, 429 errors and retries
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 concurrent requests and 60 per minute. The body can be up to 8 MB. Every response includes X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, so log them when something looks odd.
When you cross a limit you get HTTP 429. The error code tells you which one: rate_limited means too many requests per minute, and concurrency means too many at once. On temporary overload you also get 429, with a Retry-After: 5 header. In all three cases the fix is to wait and try again. Failed or refused requests are not charged, so a retry loop does not cost you for the misses.
import time
from openai import OpenAI, RateLimitError
client = OpenAI(base_url="https://api.unrestrictedgrok.com/v1", api_key="YOUR_API_KEY", max_retries=0)
def ask(messages, tries=5):
for attempt in range(tries):
try:
r = client.chat.completions.create(model="uncensored", messages=messages)
return r.choices[0].message.content
except RateLimitError:
time.sleep(5 * (attempt + 1))
raise RuntimeError("still rate limited after retries")The OpenAI SDKs already retry a couple of times by default. The snippet above turns that off to show the loop explicitly; in production you can leave the SDK default on and raise max_retries a little. If you run a batch job, cap your worker pool at 8 for a full key, or at 2 on a trial key, and you will rarely see concurrency at all.
What to change when you port GPT code
Most migrations come down to a short checklist.
- Replace the base URL with
https://api.unrestrictedgrok.com/v1and use your own key from this service. - Replace every model name with
uncensored. There is a single model, so there is nothing to choose between. - Remove calls to embeddings, image, audio and fine-tuning endpoints. They are not offered here.
- Check your prompt budget. The window is 100,000 tokens in total, so long documents plus a long answer must fit together.
- Re-test prompts that relied on another model's habits. A different model reads instructions in its own way, so a system prompt may need small edits.
The model answers without content refusals for lawful adult use. One hard limit stays in place: no sexual content involving minors. Prompts are not used for training. For the wider picture of how this endpoint relates to the official Grok API, see the comparison guide.
More guides
Questions and answers
Is this the official GPT API?
No. It is an independent, OpenAI-compatible endpoint for one open-weight model with the ID uncensored. It is not an OpenAI product.
Do I need a special SDK?
No. The official OpenAI SDKs for Python and Node work after you set the base URL and key. Plain curl or any HTTP client also works.
Can I try it without paying?
Yes. After sign-up you can claim $0.50 of trial credit on the API key page. It needs no payment and lasts 7 days.
What happens if I hit a rate limit?
You receive HTTP 429 with the code rate_limited or concurrency. Wait a few seconds and retry; limited or failed requests are not charged.
