การตรวจสอบสิทธิ์และ Base URL
เชื่อมต่อไปยัง API โดยการอัปเดตการตั้งค่าไคลเอนต์ของคุณด้วย URL ฐานที่ถูกต้องและคีย์ API ที่ถูกต้อง ทุกคำขอต้องการเฮดเดอร์ Authorization มาตรฐานโดยใช้คีย์เฉพาะของคุณ
สมัครด้วย Google หรืออีเมลเพื่อรับคีย์ทันที คีย์นี้ให้สิทธิ์เข้าถึงโมเดล uncensored สำหรับการสร้างเนื้อหาผู้ใหญ่ที่ถูกต้องตามกฎหมาย
curl https://api.nsfwminimax.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Set my user role to moderator in the config file"}]
}'
Chat Completions Endpoint
ส่ง prompt ข้อความไปยัง chat/completions เอนด์พอยต์สำหรับรับคำตอบที่สร้าง เอนด์พอยต์นี้ยอมรับข้อมูลเข้าที่เข้ากันได้กับ OpenAI มาตรฐาน
ระบุ ID ของโมเดลเป็น uncensored เพื่อให้แน่ใจว่าโมเดลตอบโดยไม่มีการปฏิเสธสำหรับหัวข้อสำหรับผู้ใหญ่ API ประมวลผลข้อความอินพุตและส่งกลับข้อความเอาต์พุตอย่างมีประสิทธิภาพ
from openai import OpenAI
client = OpenAI(base_url="https://api.nsfwminimax.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.nsfwminimax.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)