API 文件
使用標準 OpenAI 相容端點,開始使用 NSFW LLM 線上 API。零配置即可在幾秒鐘內發送您的第一個提示。
基礎 URL 與驗證
NSFW LLM 線上 API 運行於單一基礎 URL: https://api.nsfwllmonline.com/v1. 認證依賴於透過 Authorization 標頭. 您每個帳戶會收到一組活躍金鑰,您可以透過儀表板立即重新產生,且不會遺失預付餘額。
- 基礎 URL:
https://api.nsfwllmonline.com/v1 - 標頭:
Authorization: Bearer YOUR_API_KEY
curl https://api.nsfwllmonline.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Return 200 ok json"}]
}'
聊天完成端點
使用 POST /v1/chat/completions 生成文字。傳送模型 ID 為 uncensored 存取我們針對無限制回應調整的開源權重模型。API 接受標準訊息結構,允許您建構富含上下文的對話或簡單的單輪查詢。
from openai import OpenAI
client = OpenAI(base_url="https://api.nsfwllmonline.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)
支援的參數
使用標準參數(如 temperature)控制生成行為。 temperature, top_p,以及 stop. 您可以使用以下方法強制輸出 JSON。 response_format 或設定 seed 用於確保結果可重現。該模型支援 100,000 個 token 的上下文視窗,包含輸入和輸出。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.nsfwllmonline.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);
串流回應
在請求主體中將 stream: true. API 為即時 token 交付返回伺服器發送的事件 (SSE)。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 模式
使用 tool_choice 和 tools 用於函式呼叫功能。對於嚴格的結構化輸出,設定 response_format 以 {"type": "json_object"}. 這可確保自動化管線的可靠解析,無需手動的正規表達式清理。
速率限制與配額
每個金鑰允許每分鐘 300 次請求和 8 個並發請求。主體大小超過 8 MB 的請求將被拒絕。常見錯誤包括 401 用於金鑰無效, 402 用於預付信用不足,以及 429 用於速率限制。無審查模型拒絕涉及未成年人的性內容,但允許其他合法的成人主題。