Gemini API Example and an OpenAI-Style Equivalent
Here is a typical request shape for the Gemini API and the matching call in OpenAI chat format. The second one runs against our endpoint with model ID uncensored, so you change the base URL and key and keep your SDK.
Updated

The two request shapes side by side
Searching for a gemini api example usually means you want to see the smallest working request and understand how it maps onto the client you already use. The Gemini API is Google's own interface, and its request layout differs from the OpenAI chat format: as publicly documented, a Gemini call sends a list of content parts rather than a list of role and content messages, and the system prompt and generation settings sit in their own fields. Field names can change between versions, so take the exact payload from Google's current reference rather than from a blog post, this one included.
The OpenAI chat format, which our endpoint speaks, is simpler to describe. You send a model and a messages array where every item has a role (system, user, assistant or tool) and a content string. The answer comes back in choices[0].message.content. Hundreds of tools already speak this format, which is why it is a convenient common denominator when you want to switch providers without rewriting the app.
One clarification before the code: this site is not Google's and does not serve Gemini. The endpoint runs a single open-weight model that is tuned to answer without content refusals for lawful adult use. Below, "moving" means moving your calling code to an OpenAI-compatible interface, not getting Gemini through a different door.
Minimal request in Python
Install the official SDK with pip install openai, create a key on the API key page, and run this:
from openai import OpenAI
client = OpenAI(
base_url="https://api.uncensoredgemini.com/v1",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain idempotency in two sentences."},
],
temperature=0.7,
)
print(resp.choices[0].message.content)
print(resp.usage.prompt_tokens, resp.usage.completion_tokens)
Compared with a Gemini-style call, three things change in your head. The system prompt is just the first message with role: "system". Settings such as temperature are top-level arguments. And the model name is the fixed string uncensored. You can confirm what the server offers with GET /v1/models, which returns that single model.
The same call from Node and curl
The Node SDK mirrors the Python one:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uncensoredgemini.com/v1",
apiKey: process.env.API_KEY,
});
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Give me three names for a build-status bot." }],
});
console.log(resp.choices[0].message.content);
And plain curl, useful for checking a key or reading headers:
curl -i https://api.uncensoredgemini.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"ping"}]}'
The -i flag prints the response headers. Look for X-Request-Id (quote it in a support message), X-Balance-USD (your remaining credit) and the two rate-limit headers, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency.
Streaming
Set stream: true and the server sends Server-Sent Events. The last chunk carries token usage when you ask for it, so you can log cost without a second call.
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredgemini.com/v1", api_key="YOUR_KEY")
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a short scene set in a lighthouse."}],
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)
One practical detail: a streamed request occupies its concurrency slot until the stream ends. A full key allows 8 requests at once and a trial key allows 2, so close streams you no longer read, for example when a user navigates away. Otherwise a later request can come back as HTTP 429 with the code concurrency.
Tool calling
Tool calling uses the standard tools and tool_choice fields. The model replies with tool_calls, you run the function, and you send the result back as a message with role: "tool".
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredgemini.com/v1", api_key="YOUR_KEY")
tools = [{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Look up an order by its id",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}]
messages = [{"role": "user", "content": "Where is order A-1042?"}]
first = client.chat.completions.create(
model="uncensored", messages=messages, tools=tools, tool_choice="auto"
)
call = first.choices[0].message.tool_calls[0]
args = json.loads(call.function.arguments)
result = {"order_id": args["order_id"], "status": "shipped"}
messages.append(first.choices[0].message)
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)
Always parse arguments with a JSON parser and validate it before acting on it. Models can produce malformed arguments now and then, and your function should reject them instead of trusting them. In production, guard the first call against a missing tool_calls list as well, since the model may decide to answer directly.
JSON mode and sampling settings
For structured output, pass response_format with type json_object, and say in the prompt that you want JSON. The word JSON in the instructions keeps the model from drifting into prose.
from openai import OpenAI
import json
client = OpenAI(base_url="https://api.uncensoredgemini.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "Reply only with a JSON object."},
{"role": "user", "content": "Extract name and city: 'Mara lives in Porto.'"},
],
response_format={"type": "json_object"},
temperature=0,
seed=7,
)
data = json.loads(resp.choices[0].message.content)
print(data)
The sampling controls temperature, top_p, stop, seed and the frequency and presence penalties are passed through to the model. A fixed seed with temperature 0 gives you the most repeatable runs for tests. Even so, treat exact repeatability as a goal, not a guarantee.
Keeping a conversation going
The API is stateless. Each request must carry whatever context the model should see, so a multi-turn chat is a loop that appends to the same messages list. After every answer you add the assistant message, then the next user message, and send the whole list again. Nothing is remembered on the server between calls.
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredgemini.com/v1", api_key="YOUR_KEY")
history = [{"role": "system", "content": "You are a patient tutor."}]
def ask(text):
history.append({"role": "user", "content": text})
r = client.chat.completions.create(model="uncensored", messages=history)
reply = r.choices[0].message.content
history.append({"role": "assistant", "content": reply})
return reply
print(ask("What is a hash map?"))
print(ask("Show me a collision example."))
Because the whole history is billed as input on every turn, long sessions get more expensive per turn as they grow. The 100,000 token window is generous, but you do not have to fill it. A simple policy is to keep the system prompt, drop the oldest turns once the list passes a size you choose, and optionally replace them with a short summary that you ask the model to write. That keeps cost flat and answers focused.
Gemini-style code often relies on a chat session object that holds history for you. In the OpenAI format you hold it yourself, which is a few lines of code and gives you full control over what the model sees, including the ability to edit or delete past turns.
Migration checklist
If you have working code against another API and want to try this endpoint, go through these steps in order. Most projects finish in under an hour.
- Create an account and claim the trial from the API key page. Store the key in an environment variable, never in source control.
- Switch the client to an OpenAI SDK, or to the OpenAI-compatible mode of the library you already use. Set the base URL to
https://api.uncensoredgemini.com/v1. - Convert your prompt layout: system text becomes a
systemmessage, every turn becomes auserorassistantmessage, and generation settings become top-level arguments. - Set the model to
uncensored. Remove any parameters that only exist in the previous API, such as vendor-specific safety settings. - Replay a set of real prompts and compare the outputs. Judge style, accuracy on your task and how often the model follows format instructions.
- Add retry logic for HTTP 429, reading
Retry-Afterwhen present, and logX-Request-Idwith every failure. - Move the base URL and model into configuration so you can compare providers without a code change.
Two differences deserve attention. First, this is text only. If your current code sends images or audio, that part will not move over. Second, this is a different model from any big vendor's flagship, so prompts tuned for one model may need small edits, especially where you relied on a particular output style.
Errors, limits and cost
The failures you will meet are few. A wrong or missing key returns an authentication error. Too many requests per minute returns HTTP 429 with the code rate_limited. Too many at once returns 429 with the code concurrency. Temporary overload also returns 429, with a Retry-After: 5 header. The sensible client behaviour is to wait the number of seconds in that header and try again, with a cap on retries. Failed or refused requests are not charged.
Cost is easy to estimate. At $0.15 per 1M input tokens and $0.50 per 1M output tokens, a call with 1,500 tokens in and 400 out costs 1,500 x $0.15 / 1M = $0.000225 plus 400 x $0.50 / 1M = $0.0002, so $0.000425 in total. The $0.50 trial credit, available after sign-up with one click and valid for 7 days, covers about 1,176 of those calls ($0.50 / $0.000425). The request body can be up to 8 MB and the context window is 100,000 tokens, prompt and completion together.
Next steps: the quickstart lists every parameter, and the pricing page shows top-up amounts and bonuses. This site takes crypto only, USDT on TRC20 or USDC on Base.
More guides
Questions and answers
Can I use the Gemini SDK with this endpoint?
No. The endpoint speaks the OpenAI chat completions format, so use an OpenAI SDK or any OpenAI-compatible client with a different base URL and key.
What model name do I send?
Send uncensored as the model value. GET /v1/models returns the same ID.
Does the endpoint support streaming and JSON mode?
Yes. Use stream true for SSE, and response_format with type json_object for JSON mode. Tool calling is supported as well.
Is this the Gemini API?
No. It is not Google's service. It hosts one open-weight model from an independent provider behind an OpenAI-compatible interface.
How many requests can I send?
A full key allows 8 concurrent requests and 300 per minute. A trial key allows 2 concurrent and 60 per minute.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.