繁中 ▾

Uncensord ai API 文件

在幾分鐘內使用我們的無審查 LLM API 開始生成文本。本指南涵蓋驗證、端點和標準 OpenAI 相容客戶端的整合。

https://api.uncensordai.com/v1uncensored

API Base URL 與身份驗證

使用標準 OpenAI 基礎 URL 和您的 API 金鑰進行連接。我們對所有請求使用單一 bearer token,確保與現有 SDK 的相容性。

您的金鑰在註冊後立即發行。請妥善保管。

  • 基礎 URL: https://api.uncensordai.com/v1
  • 驗證:標頭中的 Bearer 權杖 Authorization 標頭
curl https://api.uncensordai.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "What is the current version of python"}]
  }'

聊天完成端點

發送訊息至 /v1/chat/completions 端點。模型 ID 為 uncensored.

請求回傳文字回應。上下文視窗為 100,000 個 token。最大輸出為 16,000 個 token。

from openai import OpenAI

client = OpenAI(base_url="https://api.uncensordai.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)

SDK 整合範例

使用官方 OpenAI SDK 或任何相容的客戶端。設定 base URL 和 API 金鑰。

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.uncensordai.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);

支援透過伺服器發送事件 (SSE) 進行串流傳輸。

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)

串流回應與 Token 用量

在請求主體中將 stream: true. 權杖使用情況出現在最後一個區塊中。

每個區塊包含部分文字。將它們聚合以構建完整回應。

參數:Temperature、Top P 和 Stop

使用標準參數控制生成。使用 temperature 用於隨機性。

設定 top_p 用於核採樣。定義 stop 序列以停止生成。JSON 模式使用 response_format: {"type": "json_object"}.

錯誤處理與速率限制

優雅地處理錯誤。代碼 401 表示無效。代碼 402 表示沒有信用額度。代碼 429 表示超過速率限制。

限制為每分鐘 300 次請求。上下文窗口為 100,000 token。錯誤免費。

常見問題

uncensored AI 的上下文視窗為何?

提示與補全的上下文視窗總計為 100,000 tokens。每次請求的最大輸出為 16,000 tokens。

我如何驗證無審查 AI API?

將您的 API 金鑰以 Bearer token 的形式包含在 Authorization 標頭中。請使用文件中提供的基礎 URL。

uncensored AI API 是否支援串流?

是的,支援透過伺服器發送事件(SSE)進行串流。Token 使用情況報告在最末一個區塊中。

取得您的 API 金鑰

註冊、複製金鑰、更新基礎 URL。設定已完成。

開啟帳戶