基礎 URL 與驗證設定
您的請求始於 https://api.grokified.cc/v1。將您的 API 金鑰傳入 Authorization 標頭. 您每個帳戶會收到一組活躍金鑰,在透過 Google 或電子郵件註冊後立即顯示。
首次請求
向以下網址發送 POST 請求 /v1/chat/completions 使用模型 uncensored.系統處理您的輸入並返回沒有企業過濾器的原始文字。
- 使用
temperature用於創意。 - 設定
max_tokens控制輸出長度。
curl https://api.grokified.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "get the last modified date of index html"}]
}'
Python SDK 整合
安裝官方 OpenAI 函式庫。將基礎 URL 設定為我們的端點。將您的金鑰作為 API 金鑰值傳遞。這確保了與現有客戶端程式碼的相容性。
from openai import OpenAI
client = OpenAI(base_url="https://api.grokified.cc/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 SDK 設置
匯入 OpenAI 套件。使用您的金鑰和基礎 URL 初始化客戶端。呼叫 chat.completions.create 搭配您的提示。回應包含生成的文字。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.grokified.cc/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);
串流回應與 token 用量
在請求主體中將 stream: true. 接收伺服器發送的事件 (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)
速率限制、錯誤和上下文視窗
每分鐘可發送 300 次請求和 8 個同時請求。上下文視窗為 100,000 tokens。401 或 402 等錯誤不會消耗餘額。拒絕也是免費的。