GPT 6 Luna API
Gửi tin nhắn qua Chat Completions và nhận toàn bộ câu trả lời hoặc đọc theo luồng. Bảng giá tách riêng token đầu vào, đầu ra và bộ nhớ đệm.
gpt-6-luna Giá tham khảo · tính theo token thực tế
Làm sao hiển thị câu trả lời ngay khi đang tạo?
Khi làm giao diện trò chuyện, đặt stream thành true để đọc từng phần. Hãy kiểm tra định dạng tin nhắn bằng yêu cầu thông thường trước khi xử lý luồng.
POST /v1/chat/completionschoices[0].message.content Python
import os
import requests
response = requests.post(
"https://api.rokoapi.com/v1/chat/completions",
headers={"Authorization": "Bearer " + os.environ["API_KEY"]},
json={"model": "gpt-6-luna", "messages": [{"role": "user", "content": "Hello"}]},
timeout=60,
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])JavaScript · Node.js
const response = await fetch("https://api.rokoapi.com/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-6-luna",
messages: [{ role: "user", content: "Hello" }],
}),
});
if (!response.ok) throw new Error(String(response.status));
console.log((await response.json()).choices[0].message.content);Tình huống tích hợp
-
Hỗ trợ nhiều lượt: gửi lịch sử liên quan và hiển thị từng phần phản hồi.
Ví dụ yêu cầu
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "Our webhook returns HTTP 401." }, { "role": "assistant", "content": "Check whether the Authorization header is present." }, { "role": "user", "content": "The header is present. What should I check next?" } ], "max_completion_tokens": 256, "stream": true }Phản hồi thực tế
Next, verify the **authentication format and value**, not just that a header exists: - Does the endpoint expect `Authorization: Bearer …`, `Basic …`, or a provider-specific signature? Webhooks often use a signature header instead of `Authorization`. - Check for typos, extra whitespace, wrong capitalization or encoding, and an expired or rotated credential. - Confirm the sender is using the credential for the right environment and endpoint (test vs. production). - Check whether a proxy, gateway, or serverless layer is removing or changing the header before it reaches your app. - Look at logs to identify which layer returns the 401—the provider, gateway, or your application202611221254505938784048268d9d6B7wQZjaO·finish_reason: length· USD 0.00012 -
Trích JSON: mô tả các khóa rồi phân tích và kiểm tra ở phía ứng dụng.
Ví dụ yêu cầu
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "Return only a JSON object with summary and action fields. Ticket: The build failed because the lockfile references a removed package." } ], "max_completion_tokens": 256, "stream": false }Phản hồi thực tế
{"summary":"The build failed because the lockfile references a package that has been removed.","action":"Update or regenerate the lockfile to remove the stale package reference, then rerun the build to verify the fix."}202611221254577052278048268d9d6U2jViPdr·finish_reason: stop· USD 0.000046 -
Gỡ lỗi: gửi đoạn lỗi tối thiểu có thể chia sẻ và yêu cầu giả thuyết để kiểm tra.
Ví dụ yêu cầu
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "A Node.js job processes the same webhook twice after a timeout. Suggest two causes and one reproducible test for each." } ], "max_completion_tokens": 256, "stream": false }Phản hồi thực tế
Đã chạm giới hạn token trước khi có văn bản trả lời.
202611221255031218619338268d9d6Hdn7s16K·finish_reason: length· USD 0.000118 -
Tóm tắt hàng loạt: giới hạn đầu vào và ghi usage để tính chi phí từng mục.
Ví dụ yêu cầu
POST https://api.rokoapi.com/v1/chat/completions{ "model": "gpt-6-luna", "messages": [ { "role": "user", "content": "Summarize in one sentence: The weekly import completed 820 rows and skipped 17 with invalid dates. No retry has run." } ], "max_completion_tokens": 256, "stream": false }
Tham số yêu cầu
Tham số thường dùng
| Trường | Chi tiết |
|---|---|
| string · Bắt buộc | Dùng mã mô hình công khai này.gpt-6-luna |
| array · Bắt buộc | Gửi các đối tượng role/content theo thứ tự, kèm các lượt cần thiết khi hỏi tiếp. |
Tham số nâng cao
| Trường | Chi tiết |
|---|---|
| boolean · Không bắt buộc | Đặt true để nhận từng phần qua SSE. Mặc định false |
| integer · Không bắt buộc | Giới hạn số token được tạo.Ảnh hưởng chi phí |
Định giá mô hình
So sánh tất cả các gói công khai và giá hiện tại của dòng này trên một trang.
Giá tham khảo · tính theo token thực tế
- Token đầu vào
- 0,092 $ / 1 triệu token
- Token đầu ra
- 0,45 $ / 1 triệu token
- Đọc bộ nhớ đệm
- 0,092 $ / 1 triệu token
- Ghi bộ nhớ đệm
- 0,115 $ / 1 triệu token
- Ghi bộ nhớ đệm (1 giờ)
- 0,184 $ / 1 triệu token
- Token ảnh đầu vào
- 0,092 $ / 1 triệu token
- Token âm thanh đầu vào
- 0,092 $ / 1 triệu token
- Token âm thanh đầu ra
- 0,092 $ / 1 triệu token
Danh mục chưa công bố bậc ngữ cảnh. Giá tham khảo có thể thay đổi theo độ dài ngữ cảnh.
Bối cảnh
—
Đầu ra tối đa
—
- ID mô hình
-
gpt-6-luna - Nhóm khả dụng
- default, svip
- Khả năng
- chat
Tham chiếu API
Base URL là https://api.rokoapi.com/v1. Tham số model trong yêu cầu phải sử dụng ID mô hình được liệt kê ở trên.
curl https://api.rokoapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"messages": [{"role":"user","content":"Giới thiệu về bản thân bằng một câu"}]
}' Để biết thêm về tham số, giới hạn và cách truy vấn tác vụ không đồng bộ, hãy đọc Hướng dẫn phát triển GPT 6 Luna. GPT 6 Luna Tài liệu phát triển · OpenAI · Authorization