無審查 API 快速入門指南
將我們的 OpenAI 相容 API 接入現有程式碼庫,生成無內容審查的文字。您僅按 token 使用量付費,無月費或隱藏費用。
先決條件與基礎 URL
開始發送請求至我們的專屬基礎 URL。我們提供單一無過濾模型 ID,可與標準 OpenAI SDK 配合使用。
- 基礎 URL:
https://api.chatgptapipricing.com/v1 - 模型 ID:
uncensored
您需要來自儀表板的 API 金鑰。該端點僅支援標準聊天完成。
Auth header 配置
將您的 API 金鑰包含在 Authorization 每次請求的標頭。使用 Bearer 驗證您的帳戶的機制。
- 標頭:
Authorization: Bearer YOUR_API_KEY
妥善保管此金鑰。您可以隨時在帳戶設定中產生新的金鑰。
發送您的第一個聊天完成請求
向 POST 請求 /v1/chat/completions 搭配您的系統和使用者訊息。API 會根據您的提示傳回文字回應。
輸入 token 成本 $0.15 每百萬個 token。輸出 token 的成本為 $0.50 每百萬個 token。錯誤不會消耗信用額度。
curl https://api.chatgptapipricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Calculate the total tokens for this input string"}]
}'
處理串流回應
在請求主體中將 stream: true 在你的請求中。API 使用伺服器發送的事件(SSE)進行即時 token 傳輸。
每個區塊包含部分文字。最後一個區塊包含用於帳務透明度的總 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)Python
from openai import OpenAI
client = OpenAI(base_url="https://api.chatgptapipricing.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)Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.chatgptapipricing.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);