快速上手:無審查 AI 用於 編碼 API
透過替換基礎 URL 和 API 金鑰,開始生成不受內容審查限制的程式碼。本指南將引導您使用標準 OpenAI 相容客戶端進行無審查 AI 程式碼生成 API。
先決條件與基礎 URL
從儀表板取得您的 API 金鑰。使用此基礎 URL 發送所有請求: https://api.uncensoredaiforcoding.com/v1. 它與任何 OpenAI SDK 兼容。
安裝官方 SDK
在您的環境中安裝該套件。這可確保與 uncensored 編碼 AI 標準的相容性。
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredaiforcoding.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)
進行首次請求
發送簡單的完成請求以測試連線。模型 ID 為 uncensored.
curl https://api.uncensoredaiforcoding.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "get current unix timestamp in python"}]
}'
啟用串流以獲得即時輸出
串流回應以有效處理長程式碼區塊。使用 stream flag。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.uncensoredaiforcoding.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);
處理錯誤與使用量限制
預期若達到每分鐘 300 次請求會出現 429 錯誤。上下文視窗為 100,000 個 token。最大輸出為 16,000 個 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 模式進行結構化資料
對於您的程式碼解析器強制執行結構化輸出。設定 response_format 以 {"type": "json_object"}.
常見查詢
uncensored AI 用於程式設計的 API 為何?
這是一個 OpenAI 相容的 API,提供單一無審查大型語言模型。它提供經過調校的原始開放權重輸出,專為無審查程式碼生成而設計。
我如何付費?
我們僅接受加密貨幣。使用 USDT (TRC20) 或 USDC (Base) 充值。價格為每 1M 輸入 token $0.15,每 1M 輸出 token $0.50。
限制為何?
您每個金鑰每分鐘可獲得 300 次請求。上下文視窗為 100,000 個 token。每次請求最大輸出為 16,000 個 token。
產生您的 API 金鑰
註冊、複製權杖、更新端點。就是這樣。