前提条件与认证
首先创建账户并生成您的 API 密钥。使用 使用 Google 继续 或在 获取 API 密钥 页面。密钥立即显示。无需手机号码。设置您的 OPENAI_API_KEY 环境变量为此值。使用此基础 URL 发送所有请求: https://api.uncensoredaiplatform.com/v1.
curl https://api.uncensoredaiplatform.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "set max tokens to 2048 and temperature to 0.7"}]
}'
发送您的第一个请求
向以下地址发送 POST 请求 /v1/chat/completions 使用模型 ID uncensored在请求体中包含您的 messages 数组。API 返回文本响应。这适用于任何 OpenAI 兼容的客户端。在配置中更改基础 URL 和 API 密钥。使用此简单结构测试连通性。
from openai import OpenAI
client = OpenAI(base_url="https://api.uncensoredaiplatform.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.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.uncensoredaiplatform.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);流式传输
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)