開始使用 與 Uncensored API
在幾分鐘內開始使用無審查 API。本快速入門將引導您完成身份驗證、發送第一個請求以及使用標準 OpenAI 相容工具處理即時串流。
安裝 OpenAI SDK
開源 SDK 為您處理 HTTP 細節。在專案環境中安裝官方套件。此程式庫自動管理重試和 JSON 解析。
pip install openai
設定您的基礎 URL 和金鑰
將您的客戶端指向我們的特定端點。基礎 URL 可確保您的提示詞連接到我們的無審查模型叢集。驗證依賴於簡單的 bearer token。
- 基礎 URL:
https://api.aimodelswithnorestrictions.com/v1 - 金鑰:您生成的 API 金鑰
from openai import OpenAI
client = OpenAI(base_url="https://api.aimodelswithnorestrictions.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)
發送一個基本聊天完成請求
發送標準的訊息載荷。該模型返回原始文字,不對成人或爭議性主題進行篩選。錯誤和拒絕不會消耗您的預付令牌。
curl https://api.aimodelswithnorestrictions.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize the current weather conditions in Tokyo"}]
}'
啟用串流以獲取即時輸出
接收即時生成的 token。這可降低長回應的感知延遲。您可以解析串流,以在應用程式中增量顯示文字。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.aimodelswithnorestrictions.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);
設置參數:Temperature 和 Top P
控制創造力和隨機性。較低的值使回應更具決定性。較高的值鼓勵多樣化和多變的措辭。
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)
處理 JSON 模式與函式呼叫
強制執行結構化輸出以進行可靠的解析。使用 response_format: {"type": "json_object"} 用於嚴格的 JSON。函式呼叫允許模型動態執行工具。
curl https://api.aimodelswithnorestrictions.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize the current weather conditions in Tokyo"}]
}'常見問題
上下文視窗和速率限制為何?
上下文視窗總共支援 100,000 個 token。每個金鑰每分鐘限 300 次請求。每個金鑰允許 8 個同時請求。
為什麼我會收到 402 錯誤?
402 狀態表示您的預付額度已耗盡。僅對實際使用量收取 token 費用,錯誤或拒絕不計費。請透過加密貨幣充值以繼續使用。
這是官方的 OpenAI 服務嗎?
否。我們提供與 OpenAI API 格式相容的無審查 LLM。該模型不是 GPT、Claude 或其他任何供應商's 的模型。它是一個獨特的開放權重模型。
保護您的 API 金鑰
註冊、複製您的金鑰、更新端點。就是這些。