基础 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);
流式响应和令牌使用
通过将 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 个 token。401 或 402 等错误不消耗信用额度。拒绝也免费。