OpenAI 文字 可用

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 application

    202611221254505938784048268d9d6B7wQZjaO · 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

OpenAI 的其他模型系列