驗證與 base URL 設定
無審查 AI 通過 Authorization 標頭。
在儀表板上透過 Google 或電子郵件產生金鑰。基礎 URL 為 https://api.unscensoredai.com/v1.
將您的金鑰作為 Bearer token 發送。在每個請求中包含標頭以識別您的帳戶。
curl https://api.unscensoredai.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Send me to the server now."}]
}'
聊天完成端點指南
主要端點是 POST /v1/chat/completions. 它接受文字輸入並回傳文字輸出。
將模型指定為 "uncensored". 此模型不會拒絕合法的成人或爭議性話題。
以標準的 OpenAI 格式發送訊息。API 處理您的提示詞並返回補全內容。
from openai import OpenAI
client = OpenAI(base_url="https://api.unscensoredai.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
透過 SSE 的串流回應
在請求主體中將 "stream": true 在你的請求主體中。
API 回傳伺服器發送事件 (SSE)。每個區塊包含部分 token 資料。
檢查最後一個區塊以獲取總 token 用量。此方法可降低長回應的感知延遲。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unscensoredai.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);
函式呼叫與 JSON 模式
使用函式呼叫進行結構化工具互動。在請求主體中定義工具。
啟用帶有 "response_format": {"type": "json_object"} 用於一致的輸出。
設定 temperature 和 top_p 用於控制隨機性。這些參數會影響回應的變異性。
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
速率限制與錯誤處理
若 API 金鑰無效,預期 401 錯誤。402 錯誤表示預付額度不足。
速率限制為每分鐘 300 次請求,每支金鑰 8 次並行請求。遵守這些限制以避免 429 錯誤。
上下文視窗為 100,000 個 token。請求主體必須小於 8 MB。
透過檢查狀態碼處理錯誤。使用指數退避重試 429。
Token 定價計算機
定價為每 1M 輸入 token $0.15,每 1M 輸出 token $0.50。
錯誤與拒絕均免費。您只需為實際使用的 token 付費。
透過加密貨幣充值。信用額度永不過期。使用下方的計算器估算費用。
輸入您預期的 token 用量。API 根據實際用量收費。