GPT 6 Luna API
通过 Chat Completions 接收文本消息,可选择普通或流式回复。目录按输入、输出及适用的缓存用量分别列价。
gpt-6-luna 目录参考费率 · 按实际 Token 用量
如何逐步显示对话回复?
开发聊天界面时,可设置 stream 为 true 并逐段读取回复。先用普通请求验证消息格式,再接入流式处理。
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);开发场景
-
多轮客服:传入与当前问题相关的历史轮次,用流式响应尽早显示答复。
请求示例
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 }实测响应
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 -
提取 JSON:在消息内描述字段,并在应用中解析、校验和处理格式失败。
请求示例
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 }实测响应
{"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 -
排查代码:提交可公开的最小错误片段,请模型生成待验证的排查步骤。
请求示例
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 }实测响应
生成 Token 达到上限,未返回正文。
202611221255031218619338268d9d6Hdn7s16K·finish_reason: length· USD 0.000118 -
批量摘要:缩短输入并记录 usage,用实测 Token 核算每条费用。
请求示例
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 }
请求参数
常用参数
| 字段 | 说明 |
|---|---|
| string · 必填 | 使用此公开模型 ID。gpt-6-luna |
| array · 必填 | 按顺序传入 role 与 content,续聊时包含所需历史轮次。 |
高级参数
| 字段 | 说明 |
|---|---|
| boolean · 可选 | 设为 true 时请求 SSE 增量。 默认 false |
| integer · 可选 | 限制生成 Token 数量。影响费用 |
模型定价
在一个页面比较该系列的所有公开档位和当前价格。
目录参考费率 · 按实际 Token 用量
- 输入 Token
- $0.092 / 百万 Token
- 输出 Token
- $0.45 / 百万 Token
- 缓存读取
- $0.092 / 百万 Token
- 缓存写入
- $0.115 / 百万 Token
- 缓存写入(1 小时)
- $0.184 / 百万 Token
- 图片输入 Token
- $0.092 / 百万 Token
- 音频输入 Token
- $0.092 / 百万 Token
- 音频输出 Token
- $0.092 / 百万 Token
目录未列出上下文档位,参考费率不代表所有上下文长度。
上下文
—
最大输出
—
- 模型 ID
-
gpt-6-luna - 可用分组
- default, svip
- 能力
- chat
API 参考
Base URL 为 https://api.rokoapi.com/v1。请求中的 model 必须使用上方列出的模型 ID。
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":"用一句话介绍你自己"}]
}' 更多参数、限制和异步任务查询方式,请阅读 GPT 6 Luna 开发指南。 GPT 6 Luna 开发文档 · OpenAI · Authorization