無需綁卡。註冊後,點擊一次即可領取 $0.50 免費試用額度(每人限領一次)。
取得 API 金鑰簡短版本
無審查 LLM API 是一個託管模型端點,針對合法成人用途設計,不會拒絕回應。這裡是一個由獨立供應商運營的單一開放權重模型,透過 POST /v1/chat/completions 和 GET /v1/models 提供。如果你的程式碼已經能與 OpenAI 風格的端點通訊,你只需將 Base URL 改為 https://api.claudensfw.cc/v1,在 Bearer 標頭放入你的金鑰,並將模型設為 uncensored。
這就是整個整合。本頁其餘部分是詳細資訊:三種語言的首次請求、可用的功能、限制行為以及請求的美元成本。如果您想要最短的路徑,文件中的快速入門將在五分鐘內涵蓋相同內容。
取得金鑰並測試
使用 Google 或電子郵件和密碼註冊。在 API 金鑰頁面,您可以一鍵領取 $0.50 試用額度。每人限領一次,有效期為 7 天,無需付款。開啟 金鑰頁面 以建立金鑰並複製一次。
將金鑰保留在程式碼之外。將其匯出為環境變數並從那裡讀取:
export API_KEY="paste-your-key-here"試用金鑰限制為 2 個並行請求和每分鐘 60 個請求。完整金鑰(在您添加額度後獲得)允許 8 個並行請求和每分鐘 300 個請求。這對於測試和大多數單一應用程式負載來說已經足夠。
curl、Python 和 Node 的首次請求
從 curl 開始,因為它消除了所有其他變數。如果這可行,任何客戶端都可以。
curl https://api.claudensfw.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "You are a blunt, helpful writing partner."},
{"role": "user", "content": "Draft a tense opening scene for a noir story."}
]
}'回覆具有通常的格式:choices[0].message.content 保存文本,usage 保存 token 計數。回應標頭還包含 X-Request-Id、X-Balance-USD 和兩個速率限制標頭,這使得在每次呼叫時輕鬆記錄剩餘餘額變得容易。
Python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.claudensfw.cc/v1",
api_key=os.environ["API_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a blunt, helpful writing partner."},
{"role": "user", "content": "Draft a tense opening scene for a noir story."},
],
temperature=0.8,
)
print(resp.choices[0].message.content)
print(resp.usage)Node
官方的 openai 套件以相同的方式運作。範例使用 ES 模組,因此將其儲存為 .mjs 檔案或在 package.json 中設定 "type": "module"。
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.claudensfw.cc/v1",
apiKey: process.env.API_KEY,
});
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Give me three names for a harbor town." }],
});
console.log(resp.choices[0].message.content);串流輸出、JSON 模式和工具
設定 stream: true,伺服器會在產生文本時發送 Server-Sent Events,並在結尾處包含 usage 區塊。對於長篇創意輸出,這是在即時填充的頁面和在空白處停留一分鐘之間的區別。
# client = OpenAI(base_url="https://api.claudensfw.cc/v1", ...) as in the first example
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a short monologue for a retired smuggler."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print("\n", chunk.usage)透過 response_format 參數啟用 JSON 模式。請在提示詞中指定你需要的鍵,因為該參數僅保證 JSON 語法有效,但不保證符合你的結構定義。
# client = OpenAI(base_url="https://api.claudensfw.cc/v1", ...) as in the first example
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "Reply with a JSON object with keys name, role and backstory."},
{"role": "user", "content": "Create a side character for a space western."},
],
response_format={"type": "json_object"},
)工具呼叫遵循 OpenAI 格式:傳遞 tools 和 tool_choice,從回覆中讀取 tool_calls,自行執行函式,然後以 role: "tool" 將結果作為訊息發送。串流回應將 tool_calls 作為增量攜帶。
# client = OpenAI(base_url="https://api.claudensfw.cc/v1", ...) as in the first example
tools = [{
"type": "function",
"function": {
"name": "roll_dice",
"description": "Roll a die with the given number of sides",
"parameters": {
"type": "object",
"properties": {"sides": {"type": "integer"}},
"required": ["sides"],
},
},
}]
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Roll a d20 for the lockpicking check."}],
tools=tools,
tool_choice="auto",
)
print(resp.choices[0].message.tool_calls)temperature、top_p、stop、seed 等採樣設定以及懲罰都會傳遞給模型。上下文視窗為 100,000 個 token,計算提示詞和補全內容的總和,max_tokens 是可選的。
限制與 429 的含義
實務上有兩個限制:每分鐘請求數與同時請求數。當超過前者時,API 會回傳 HTTP 429 並附上錯誤碼 rate_limited。當超過後者時,會回傳 429 並附上程式碼 concurrency。在暫時過載時,你也會收到 429,並帶有 Retry-After: 5 標頭,因此等待五秒是正確的處理方式。
一個容易讓人忽略的細節是:串流請求會佔用並行槽位,直到串流結束為止。八個使用者正在讀取八個長串流時,即使每分鐘請求數很低,也會阻塞第九個請求。在客戶端前方加入小型佇列或信號量即可解決此問題。
# client = OpenAI(base_url="https://api.claudensfw.cc/v1", ...) as in the first example
import time
from openai import RateLimitError
def ask(messages, tries=4):
for attempt in range(tries):
try:
return client.chat.completions.create(model="uncensored", messages=messages)
except RateLimitError:
time.sleep(5 * (attempt + 1))
raise RuntimeError("still rate limited after retries; base URL: https://api.claudensfw.cc/v1")最大請求主體為 8 MB。這遠高於 100,000 個 token 提示詞所需的大小,因此只有在將大型編碼檔案嵌入文本時才會達到此限制。
模型能做和不能做的事
該模型是開放權重的,並且經過調校,不會因內容原因而拒絕,適合小說、角色扮演、伴侶應用程式、敏感主題研究和成人審核工具。它不是 Meta、Mistral、Qwen、DeepSeek、OpenAI、xAI、Google、Anthropic 或其他任何供應商官方 API,也不是跨供應商的路由器。您正在與一個模型對話。
有三個界限是固定的。涉及未成年人的性內容永遠不被允許。該服務僅限文本,因此沒有圖像、音訊或影片生成,沒有嵌入和微調。合法使用由您負責:移除拒絕並不移除法律或您部署的平台規則。提示詞不用於訓練。
成本與使用加密貨幣付款
定價為每 1M 輸入 token $0.15,每 1M 輸出 token $0.50,從預付額度中計費,無訂閱。失敗或被拒絕的請求不會收費,且額度永不過期。一次典型的聊天輪次包含 2,000 個輸入 token 和 500 個輸出 token,輸入成本為 $0.0003,輸出成本為 $0.00025,總計 $0.00055。$0.50 的試用額度大約可覆蓋 900 次此類請求。
儲值金額為 $20 至 $500 的整數,以 TRC20 上的 USDT 或 Base 上的 USDC 支付。獎金為從 $50 起 5%、從 $100 起 10%、從 $200 起 15%,因此 $100 給予 $110 額度,$200 給予 $230。詳細資訊和範例請見 定價頁面。請監控回應標頭中的 X-Balance-USD 以知道何時儲值。
如果您遇到本頁未解釋的問題,支援頁面 列出了聯繫我們的方式,並引用失敗回應中的 X-Request-Id 可以加快處理速度。
