快速入門: 整合 obliterated 模型
別再與代理包裝器糾纏。使用標準的 OpenAI 相容端點,立即將文本發送給非過濾 LLM。
安裝與 SDK 設定
安裝您偏好的函式庫並將基礎 URL 設定為指向我們的基礎設施。
pip install openai
將基礎 URL 設定為 https://api.obliteratedmodel.com/v1 並插入您的 API 金鑰。這適用於任何遵循標準規範的客戶端。
使用 Google 或電子郵件註冊後,從儀表板檢索您的金鑰。驗證不需要電話號碼。
確保您的金鑰處於啟用狀態後再發出請求。
- 安裝 SDK。
- 設定基礎 URL。
- 插入您的 API 金鑰。
from openai import OpenAI
client = OpenAI(base_url="https://api.obliteratedmodel.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)
/v1/chat/completions 端點
向聊天補全端點發送 POST 請求以接收文本回應。
使用模型識別碼 uncensored 在您的請求主體中。該端點接受標準參數,如 temperature 和 top_p.
輸入 token 按每百萬個 $0.15 收費,輸出 token 每百萬個成本為 $0.50。錯誤不消耗信用額度。
curl https://api.obliteratedmodel.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "List the top 5 linux commands for disk usage."}]
}'
串流回應與 token 計數
在請求主體中將 stream: true 在你的請求主體中。
API 透過伺服器發送事件 (Server-Sent Events) 回傳資料區塊。Token 使用詳細資訊會出現在串流的最後一個區塊中。
設置最大 token 限制以控制輸出長度。如果您未指定值,默認值為 2,048 個 token。
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 模式
使用 JSON 模式或函數調用構造您的響應。
設定 response_format 以 {"type": "json_object"} 用於嚴格的 JSON 輸出。使用 tools 參數用於函數呼叫功能。
此功能可讓您在應用程式中進行程式化整合,無需解析雜亂的文字。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.obliteratedmodel.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 與 seed
使用標準採樣參數控制隨機性與可重複性。
調整 temperature 用於創意, top_p 用於核採樣,以及 seed 用於確定性輸出。
這些參數影響無審查模型生成文本的方式。使用 stop 序列以提前停止生成。
存在懲罰與頻率懲罰有助於減少長上下文中的重複內容。
處理限制與錯誤
監控您的請求速率和餘額以避免中斷。
限制為每分鐘每金鑰 300 次請求。您可以同時執行 8 個請求。
透過檢查 API 金鑰的有效性來處理 401 錯誤。透過使用加密貨幣充值來解決 402 錯誤。
透過實施指數退避來管理 429 速率限制錯誤。上下文視窗支援 100,000 個 token,包含輸入和完成內容。
請求主體不得超過 8 MB。
獲取 your API key
註冊,複製金鑰,更新端點。就是這樣。