API 文档
使用标准的 OpenAI 兼容端点开始使用 NSFW LLM 在线 API。零配置即可在几秒钟内发送您的第一个提示。
基础 URL 和认证
NSFW LLM 在线 API 基于单一基础 URL 运行: https://api.nsfwllmonline.com/v1. 身份验证依赖于通过 Authorization 头部,您获得每个账户一个活跃密钥,可在仪表板上立即重新生成,且不会丢失预付费余额。
- 基础 URL:
https://api.nsfwllmonline.com/v1 - 标头:
Authorization: Bearer YOUR_API_KEY
curl https://api.nsfwllmonline.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Return 200 ok json"}]
}'
聊天完成端点
使用 POST /v1/chat/completions 生成文本。发送模型 ID 为 uncensored 访问我们针对无限制响应进行调优的开源权重模型。API 接受标准消息结构,允许你构建上下文丰富的对话或简单的单轮查询。
from openai import OpenAI
client = OpenAI(base_url="https://api.nsfwllmonline.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)
支持的参数
使用标准参数控制生成行为,例如 temperature, top_p,以及 stop. 您可以使用以下方法强制输出 JSON 格式 response_format 或设置一个 seed 用于确保可复现性。该模型支持 100,000 个 token 的上下文窗口,包含输入和输出。
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.nsfwllmonline.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: true. API 为实时令牌交付返回 Server-Sent Events (SSE)。令牌使用元数据仅出现在最后一个块中,确保在不阻塞响应流的情况下准确跟踪计费。
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 模式
使用 tool_choice 和 tools 用于函数调用功能。对于严格的结构化输出,请设置 response_format 到 {"type": "json_object"}. 这确保了自动化管道中的可靠解析,无需手动正则表达式清理。
速率限制与配额
每个密钥允许每分钟 300 次请求和 8 个并发请求。主体大小超过 8 MB 的请求将被拒绝。常见错误包括 401 用于密钥无效, 402 用于预付费余额不足,以及 429 用于速率限制。无审查模型拒绝涉及未成年人的性内容,但允许其他合法的成人话题。