คู่มือเริ่มต้นใช้งาน API แบบไม่มีเซนเซอร์อย่างรวดเร็ว
ใส่ API ที่เข้ากันได้กับ OpenAI ของเราลงในโค้ดเบสที่มีอยู่ของคุณเพื่อสร้างข้อความโดยไม่มีตัวกรองเนื้อหา คุณจ่ายตามการใช้งานโทเคนเท่านั้น ไม่มีค่าสมัครสมาชิกรายเดือนหรือค่าธรรมเนียมที่ซ่อนอยู่
ข้อกำหนดเบื้องต้นและ URL ฐาน
เริ่มด้วยการส่งคำขอไปยัง URL ฐานเฉพาะของเรา เราให้ ID โมเดล uncensored เพียงตัวเดียวที่ใช้งานร่วมกับ SDK ของ OpenAI มาตรฐาน
- Base URL:
https://api.chatgptapipricing.com/v1 - ID โมเดล:
uncensored
คุณต้องมีคีย์ API จากแดชบอร์ด จุดเชื่อมต่อรองรับเฉพาะการเสร็จสิ้นการสนทนาตามมาตรฐาน
การกำหนดค่า Auth header
รวมคีย์ API ของคุณใน Authorization header สำหรับการร้องขอทุกชิ้น ใช้ Bearer scheme เพื่อตรวจสอบบัญชีของคุณ
- ส่วนหัว:
Authorization: Bearer YOUR_API_KEY
เก็บคีย์นี้ให้ปลอดภัย คุณสามารถสร้างคีย์ใหม่ได้ทุกเมื่อจากการตั้งค่าบัญชี
การส่ง chat completion ครั้งแรกของคุณ
ทำการร้องขอ POST ไปยัง /v1/chat/completions พร้อมข้อความระบบและข้อความผู้ใช้ของคุณ API ส่งคืนข้อความตอบกลับตามพรอมต์ของคุณ
โทเค็นอินพุตมีค่าใช้จ่าย $0.15 per 1M tokens ค่าใช้จ่ายของ output tokens คือ $0.50 per 1M tokens ข้อผิดพลาดไม่ใช้เครดิต
curl https://api.chatgptapipricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Calculate the total tokens for this input string"}]
}'
การจัดการการตอบกลับแบบสตรีม
เปิดใช้งานการสตรีมโดยตั้งค่า stream: true ในการร้องขอของคุณ API จะส่ง Server-Sent Events (SSE) เพื่อส่งโทเค็นแบบเรียลไทม์
แต่ละ chunk มีข้อความบางส่วน chunk สุดท้ายรวมการใช้งาน token ทั้งหมดเพื่อความโปร่งใสในการเรียกเก็บเงิน
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)Python
from openai import OpenAI
client = OpenAI(base_url="https://api.chatgptapipricing.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.chatgptapipricing.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);