繁中 ▾
開啟帳戶
  1. GrokBezcenzury
  2. 開發者快速入門指南

開發者快速入門指南

透過 OpenAI 相容的 API 連接無限制 LLM。本指南涵蓋基礎 URL、身份驗證和核心請求結構。

前置條件:金鑰與基礎 URL

The base_url 是 https://api.grokbezcenzury.com/v1. 您需要有效的 API 金鑰進行授權。金鑰在您透過 Google 或電子郵件註冊後立即顯示。

發送您的第一個請求

向以下網址發送 POST 請求 /v1/chat/completions. 使用模型 ID uncensored 用於回應。

curl https://api.grokbezcenzury.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Generate 200 lines of Python code"}]
  }'

Python SDK 集成

使用您的基礎 URL 和金鑰初始化客戶端。將模型設定為 uncensored. SDK 自動處理序列化。

from openai import OpenAI

client = OpenAI(base_url="https://api.grokbezcenzury.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 SDK 設置

將客戶端配置為指向我們的基礎 URL。傳遞模型 ID uncensored 在您的完成呼叫中。

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.grokbezcenzury.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: true 接收伺服器發送的事件。最後一個區塊包含 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)

限制、錯誤與上下文

上下文視窗為 100,000 個 token。金鑰無效時會收到 401 錯誤。剩餘信用額度為零時會收到 402 錯誤。達到每分鐘 300 次請求限制時會收到 429 錯誤。

常見問題

grok bez cenzury API 的基礎 URL 為何?

基礎網址為 HTTPS://api.grokbezcenzury.com/v1。它與標準的 OpenAI 相容客戶端相容。

如何處理串流回應?

將 stream 參數設為 true。您會收到伺服器發送事件,其中最後一個區塊包含使用資料。

如果我超出速率限制會發生什麼事?

您收到 429 錯誤。每支金鑰的限制為每分鐘 300 次請求。

在數秒內存取您的 API 金鑰

註冊、取得金鑰,並更新您的端點。就是這麼簡單。