繁中 ▾
取得 API 金鑰

API 文件

立即使用這些程式碼範例開始使用 NSFW 無審查 LLM API。該服務完全與 OpenAI 相容,因此您可以替換基礎 URL 和 API 金鑰以開始生成文字。

驗證與金鑰

透過 Google 或電子郵件地址註冊以取得您的 API 金鑰。金鑰會立即顯示在儀表板上。將其用作 Authorization 每次請求的標頭。

curl https://api.nsfwuncensored.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Check my plan balance"}]
  }'

聊天完成端點

將文字傳送至 POST /v1/chat/completions 並接收文字。模型 ID 為 uncensored. 輸入內容在 100,000 token 的上下文視窗內。

from openai import OpenAI

client = OpenAI(base_url="https://api.nsfwuncensored.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. 透過伺服器發送的事件接收 token。token 使用量出現在最後一個區塊。

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.nsfwuncensored.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,以及 stop 序列。使用 response_format: {"type": "json_object"} for JSON 輸出。

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)

速率限制與配額

限制為每個密鑰每分鐘 300 次請求。並發請求上限為 8。請求主體必須保持在 8 MB 以下。

錯誤與上下文視窗

401 表示金鑰無效。402 表示沒有額度。429 表示速率限制。上下文視窗總共為 100,000 個 Token。

常見 問題

網站的主要關鍵字為何?

主要關鍵字為 NSFW 無審查。此詞彙出現在專屬章節的 H2 標題中以及第一個 FAQ 問題裡。

如何在 API 中處理錯誤?

處理身份驗證問題的 401、額度不足的 402 和速率限制的 429。錯誤和拒絕是免費的。

上下文視窗的大小是多少?

提示與補全的上下文視窗總計為 100,000 tokens。沒有單獨的輸出上限:回應可以使用視窗中剩餘的所有空間。

產生您的 API 金鑰

註冊、取得你的金鑰,並更新基礎 URL。簡單的整合。

取得 API 金鑰