开始使用 与 Uncensored API
几分钟内即可开始使用无审查 API。本快速入门指导您完成身份验证、发送第一个请求以及使用标准 OpenAI 兼容工具处理实时流式传输。
安装 OpenAI SDK
开源 SDK 为您处理 HTTP 细节。在项目环境中安装官方包。该库自动管理重试和 JSON 解析。
pip install openai
配置你的基础 URL 和密钥
将您的客户端指向我们的特定端点。基础 URL 确保您的提示到达我们的 uncensored 模型集群。身份验证依赖于简单的 bearer token。
- 基础 URL:
https://api.aimodelswithnorestrictions.com/v1 - 密钥:您生成的 API 密钥
from openai import OpenAI
client = OpenAI(base_url="https://api.aimodelswithnorestrictions.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)
发送基础聊天补全
发送标准消息负载。模型返回原始文本,不对成人或争议性主题进行过滤。错误和拒绝不会消耗你的预付费令牌。
curl https://api.aimodelswithnorestrictions.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize the current weather conditions in Tokyo"}]
}'
启用流式传输以实现实时输出
接收生成的令牌。这降低了长响应的感知延迟。您可以解析流以在应用程序中增量显示文本。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.aimodelswithnorestrictions.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);
设置参数:温度和 Top P
控制创造力和随机性。较低的值使响应更确定。较高的值鼓励多样和多样的措辞。
temperature: 调整随机性。top_p: 按概率过滤词汇。
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"} 以确保严格的 JSON。函数调用允许模型动态执行工具。
curl https://api.aimodelswithnorestrictions.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize the current weather conditions in Tokyo"}]
}'常见问题
上下文窗口和速率限制是多少?
上下文窗口总共支持 100,000 个 token。每个密钥每分钟限制为 300 次请求。每个密钥允许最多 8 个并发请求。
为什么会出现 402 错误?
402 状态表示您的预充值余额已耗尽。Token 仅对实际使用量计费,错误和拒绝请求不计费。通过加密货币充值以继续服务。
这是官方的 OpenAI 服务吗?
不。我们提供与 OpenAI API 格式兼容的无审查大语言模型。该模型不是 GPT、Claude 或其他任何厂商的模型。它是一个独立的开源权重模型。
保护你的 API 密钥
注册,复制密钥,更新端点。仅此而已。