認証とベースURL
正しいベースURLと有効なAPIキーを使用してクライアント設定を更新することで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エンドポイント
テキストプロンプトを 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)