Cookbook
Every recipe runs verbatim against https://uncensoredai.dev/v1 — replace the key and go.
01
Streaming responses
Token-for-token SSE deltas in the OpenAI format — set stream:true and iterate.
Streaming responses
from openai import OpenAI
client = OpenAI(base_url="https://uncensoredai.dev/v1", api_key="YOUR_KEY")
stream = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Write a haiku about databases."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)02
Function calling
The model returns tool_calls JSON; you execute and send the tool result back in the same wire format.
Function calling
from openai import OpenAI
import json
client = OpenAI(base_url="https://uncensoredai.dev/v1", api_key="YOUR_KEY")
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
messages = [{"role": "user", "content": "Weather in Hong Kong?"}]
res = client.chat.completions.create(model="deepseek-v4.1-flash", messages=messages, tools=tools)
call = res.choices[0].message.tool_calls[0]
args = json.loads(call.function.arguments)
weather = {"city": args["city"], "temp_c": 28, "sky": "humid"} # your real lookup here
messages.append(res.choices[0].message)
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(weather)})
final = client.chat.completions.create(model="deepseek-v4.1-flash", messages=messages)
print(final.choices[0].message.content)03
Structured JSON output
response_format json_object asks the model for machine-parseable output.
Structured JSON output
from openai import OpenAI
client = OpenAI(base_url="https://uncensoredai.dev/v1", api_key="YOUR_KEY")
res = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[{
"role": "user",
"content": "Extract {name, severity, component} from: 'Checkout 500s when payment service times out.'",
}],
response_format={"type": "json_object"},
)
print(res.choices[0].message.content)04
RAG grounding
Bring your own retrieval; the pattern is retrieve → cite → answer. Works with any vector store.
RAG grounding
from openai import OpenAI
client = OpenAI(base_url="https://uncensoredai.dev/v1", api_key="YOUR_KEY")
# 1. retrieve (your vector store / BM25 / SQL — anything that ranks)
chunks = search_index("our refund window")[:5]
# 2. ground the answer
context = "\n\n".join(f"[{i+1}] {c}" for i, c in enumerate(chunks))
res = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[
{"role": "system", "content": "Answer only from the context. Cite as [n]."},
{"role": "user", "content": f"Context:\n{context}\n\nQuestion: what is our refund window?"},
],
)
print(res.choices[0].message.content)05
Vision (image input)
Gemini accepts image_url content parts with base64 or public URLs.
Vision (image input)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://uncensoredai.dev/v1", apiKey: "YOUR_KEY" });
const res = await client.chat.completions.create({
model: "gemini-4-argon",
messages: [{
role: "user",
content: [
{ type: "text", text: "What is in this image?" },
{ type: "image_url", image_url: { url: "https://example.com/diagram.png" } },
],
}],
});
console.log(res.choices[0].message.content);