GPT-6 API 怎麼用:申請金鑰並呼叫 Astra、Sol、Luna
GPT-6 API 串接教學:取得 API 金鑰,用 OpenAI SDK 呼叫 GPT-6 Astra、Sol 或 Luna,設定推理強度、串流輸出、傳送圖片,並避開常見錯誤。
以 Markdown 閱讀要呼叫 GPT-6,你需要一個提供該模型的平台所發的 API 金鑰,以及一個把 model 設為 gpt-6-astra、gpt-6-sol 或 gpt-6-luna 的請求。OpenAI 在自家 API 中提供這三個模型,GPT-6 Astra 另外也可透過 Microsoft Azure 與 Amazon Bedrock 使用。SeedRouter 以一把金鑰、按用量付費的方式提供全部三個模型,使用官方 OpenAI 請求格式:把 OpenAI SDK 指向 https://api.seedrouter.ai/v1,程式碼不用改。
本指南使用 SeedRouter;請求內容與 OpenAI 的完全相同。
GPT-6 API 金鑰怎麼取得?
- 登入 SeedRouter,開啟 API keys。
- 建立金鑰並複製;它只會顯示一次。
- 需要時再儲值。新帳戶會附一小筆免費餘額,而且沒有訂閱制。
把金鑰存在環境變數中,例如 SEEDROUTER_API_KEY,並且只在伺服器端程式碼中使用。
怎麼用 Python 呼叫 GPT-6?
OpenAI 建議 GPT-6 使用 Responses API。使用官方的 openai 套件:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["SEEDROUTER_API_KEY"],
base_url="https://api.seedrouter.ai/v1",
)
response = client.responses.create(
model="gpt-6-sol",
input="Summarize the trade-offs of event sourcing in three bullet points.",
)
print(response.output_text)把 model 改成 gpt-6-astra 或 gpt-6-luna 即可切換模型;請求中的其他部分都不需要改。
怎麼用 Node.js 或 cURL 呼叫?
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.SEEDROUTER_API_KEY,
baseURL: "https://api.seedrouter.ai/v1",
});
const response = await client.responses.create({
model: "gpt-6-sol",
input: "Summarize the trade-offs of event sourcing in three bullet points.",
});
console.log(response.output_text);curl https://api.seedrouter.ai/v1/responses \
-H "Authorization: Bearer $SEEDROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6-sol", "input": "Summarize the trade-offs of event sourcing in three bullet points."}'現有的 Chat Completions 程式碼也能用:把 messages 送到 /v1/chat/completions,並用 max_completion_tokens 設定輸出上限。
推理強度怎麼設定?
推理強度是在思考深度與速度、成本之間取捨。在 Responses API 中用 reasoning.effort 設定,在 Chat Completions 中用 reasoning_effort:
response = client.responses.create(
model="gpt-6-sol",
input="Find the bug: def avg(xs): return sum(xs) / len(xs)",
reasoning={"effort": "high"},
)| 模型 | 可接受的值 | 預設值 |
|---|---|---|
| GPT-6 Astra | low、medium、high、xhigh、max | 未公布 |
| GPT-6 Sol | none、low、medium、high、xhigh、max | medium |
| GPT-6 Luna | none、low、medium、high、xhigh、max | medium |
推理 token 以輸出 token 計費。none 會略過推理,也是唯一接受 temperature 與 top_p 的等級;GPT-6 Astra 不支援它。
怎麼串流輸出回答?
加上 stream=True 並讀取事件。文字會以 response.output_text.delta 事件陸續送達,最後的 response.completed 事件帶有 token 用量:
stream = client.responses.create(
model="gpt-6-luna",
input="Write a haiku about latency.",
stream=True,
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)可以傳送圖片嗎?
可以。三個模型都能同時讀取圖片與文字。在使用者訊息中放入一個帶公開網址的 input_image 部分:
response = client.responses.create(
model="gpt-6-sol",
input=[{
"role": "user",
"content": [
{"type": "input_image", "image_url": "https://example.com/chart.png"},
{"type": "input_text", "text": "What does this chart show?"},
],
}],
)可能會遇到哪些錯誤?
| 錯誤 | 原因 | 修正方式 |
|---|---|---|
400,max_output_tokens 低於最小值 | 設定值小於 16 | 設為 16 以上;此值同時涵蓋回答與推理 |
temperature 或 top_p 回傳 400(Responses API) | 推理強度不是 none | 移除這兩個欄位,或在 Sol、Luna 上把推理強度設為 none |
none 推理強度回傳 400 | 送給了 GPT-6 Astra | 改用 low |
| 401 | 金鑰缺少或錯誤 | 檢查 Authorization 標頭 |
錯誤會回傳 {"error": {"code": ..., "message": "..."}},而失敗的請求不收費。
常見問題
GPT-6 可以透過 API 使用了嗎?
可以。依 OpenAI 的 API 更新紀錄,GPT-6 Astra 於 2026 年 9 月 3 日在 API 上推出,GPT-6 Sol 與 GPT-6 Luna 則於 2026 年 9 月 22 日推出。
使用 GPT-6 需要 OpenAI 帳號嗎?
在 SeedRouter 上不需要。你登入 SeedRouter、在那裡建立金鑰,並從 SeedRouter 餘額付款。
應該先從哪個 GPT-6 模型開始?
大多數程式開發與代理工作用 GPT-6 Sol,大量且簡單的任務用 GPT-6 Luna,最困難的問題用 GPT-6 Astra。Astra vs Sol vs Luna 指南說明了如何選擇。
完整的參數清單在哪裡?
GPT-6 Sol、GPT-6 Luna 與 GPT-6 Astra 的 API 文件列出了每個欄位、限制與回應格式。
寫程式之前先試試看
GPT-6 Sol playground 會從你的瀏覽器送出相同的請求,並顯示每個回答的原始 JSON、token 數與費用。



