基礎 URL 與驗證
所有請求的基礎 URL 為 https://api.veniceaiapipricing.com/v1. 通過在 Authorization header 作為 bearer token。此設定適用於任何標準 OpenAI SDK。取代 YOUR_API_KEY 使用從您的帳戶儀表板生成的金鑰。
- 端點:
POST /v1/chat/completions - 標頭:
Authorization: Bearer YOUR_API_KEY
curl https://api.veniceaiapipricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Return server status code 200"}]
}'
/v1/chat/completions 端點
將您的對話歷史傳送至 /v1/chat/completions 使用 uncensored 模型 ID。API 接受標準訊息物件,並包含 role 和 content 欄位。輸入 token 每百萬計費 $0.15,輸出 token 每百萬計費 $0.50。錯誤與拒絕不會消耗信用額度。
此端點僅支援文字生成。不處理影像、音訊或嵌入向量。您可以串流回應,或將完整文字以單一 JSON 物件取得。
from openai import OpenAI
client = OpenAI(base_url="https://api.veniceaiapipricing.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 在你的請求主體中。API 會為每個生成的 token 回傳伺服器發送的事件 (SSE)。最後一個區塊包含總 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 模式
API 支援結構化輸出與工具定義。使用 response_format: {"type": "json_object"} 以強制輸出 JSON。您也可以傳遞 tools 用於函式呼叫,允許模型為您的應用程式邏輯返回結構化資料。
此功能可用於提取資料或觸發動作。模型以標準化格式返回工具呼叫。然後您可以執行函式並將結果回饋至對話中。
參數:溫度、Top P、Seeds
使用 temperature 和 top_p. 該 seed parameter ensures deterministic outputs for testing. These parameters follow standard OpenAI conventions. Adjusting them affects the randomness of the generated text.
設定 temperature 至 0.7 以取得平衡的創意。使用 seed 用於獲得可重現的結果。API 會優雅地忽略不支援的參數。
速率限制與限制條件
每支金鑰每分鐘限 300 次請求。每支金鑰最多允許 8 個同時進行的請求。請求主體大小上限為 8 MB。輸入與輸出的上下文視窗總計為 100,000 個 token。每次請求的輸出上限為 16,000 個 token。
超出這些限制會返回 429 錯誤。確保您的客戶端適當處理重試。API 金鑰為帳戶獨有;生成新金鑰將取代舊金鑰。
Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.veniceaiapipricing.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);