首頁›常見問題›OpenAI ChatGPT API

OpenAI ChatGPT API

一般問題常見問題帳戶問題功能問題隱私權
API 說明文件OpenAI ChatGPT APIAnthropic Claude APIGoogle Gemini APIGoogle News APIOpenRouter APIAPI 收費
CLI 與 Agent 教學OpenCodeOpenClawHermes AgentClaude Code CLICodex CLI
MYAI168 API 與 MCPMYAI168 MCP CLIMYAI168 MCP 網頁及應用程式
本頁沒有符合的問題。 改用全站搜尋
OpenAI#

OpenAI API 中繼

POST /stu/api/openai/v1/responses

Responses API (新版對話介面,支援 streaming)。

curl https://www.myai168.com/stu/api/openai/v1/responses \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.5","input":"Hello"}'
import requests

r = requests.post(
    "https://www.myai168.com/stu/api/openai/v1/responses",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "gpt-5.5", "input": "Hello"},
)
print(r.json())

POST /stu/api/openai/v1/chat/completions

Chat Completions API (舊版對話介面,相容 OpenAI SDK)。

curl https://www.myai168.com/stu/api/openai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.5","messages":[{"role":"user","content":"Hello"}]}'
import requests

r = requests.post(
    "https://www.myai168.com/stu/api/openai/v1/chat/completions",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello"}]},
)
print(r.json())

POST /stu/api/openai/v1/audio/speech

文字轉語音 (TTS),回 audio binary。

curl https://www.myai168.com/stu/api/openai/v1/audio/speech \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tts-1","input":"Hello","voice":"nova"}' \
  --output speech.mp3
import requests

r = requests.post(
    "https://www.myai168.com/stu/api/openai/v1/audio/speech",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "tts-1", "input": "Hello", "voice": "nova"},
)
with open("speech.mp3", "wb") as f:
    f.write(r.content)

POST /stu/api/openai/v1/audio/transcriptions

語音轉文字 (STT, multipart upload)。

curl https://www.myai168.com/stu/api/openai/v1/audio/transcriptions \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -F file=@audio.mp3 \
  -F model=gpt-4o-transcribe
import requests

with open("audio.mp3", "rb") as f:
    r = requests.post(
        "https://www.myai168.com/stu/api/openai/v1/audio/transcriptions",
        headers={"Authorization": "Bearer YOUR_DEV_KEY"},
        files={"file": f},
        data={"model": "gpt-4o-transcribe"},
    )
print(r.json())

POST /stu/api/openai/v1/audio/translations

語音翻譯成英文 (STT + translate)。

curl https://www.myai168.com/stu/api/openai/v1/audio/translations \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -F file=@audio.mp3 \
  -F model=gpt-4o-transcribe
import requests

with open("audio.mp3", "rb") as f:
    r = requests.post(
        "https://www.myai168.com/stu/api/openai/v1/audio/translations",
        headers={"Authorization": "Bearer YOUR_DEV_KEY"},
        files={"file": f},
        data={"model": "gpt-4o-transcribe"},
    )
print(r.json())

POST /stu/api/openai/v1/images/generations

文字生圖 (gpt-image-2)。

curl https://www.myai168.com/stu/api/openai/v1/images/generations \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-2","prompt":"A cute cat","size":"1024x1024"}'
import requests

r = requests.post(
    "https://www.myai168.com/stu/api/openai/v1/images/generations",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "gpt-image-2", "prompt": "A cute cat", "size": "1024x1024"},
)
print(r.json())
支援的端點與功能(支援矩陣)#

支援矩陣

部分 OpenAI SDK 功能經本站中繼時行為不同,接入前請先對照本表,避免踩坑。

  • GET /v1/models —— 支援。回傳的清單就是本中繼實際受理的模型;不在清單內的模型一律回 "No pricing info! Please use other models!"。
  • POST /v1/responses 與 POST /v1/chat/completions —— 支援,含串流。
  • 網頁搜尋 —— 支援並按次計費:Responses API 用 tools: [{"type": "web_search"}],Chat Completions 用 web_search_options。
  • 其他 hosted 工具(code_interpreter、file_search、image_generation、computer use、hosted MCP)—— 不支援,回 HTTP 400;請改用 client 端 function calling。
  • 音訊端點(speech/transcriptions/translations/voices)與 images/generations —— 支援。
  • 非串流回應帶 X-Cost-Points(本次扣點)與 X-Credits-Remaining(扣後餘額)header;也可隨時以 GET /stu/api/user/get_credits 查詢餘額。
  • 呼叫失敗或供應商未回用量資訊時,一律不收費。
請求參數、回應格式與錯誤碼#

請求參數(POST /stu/api/openai/v1/chat/completions)

請求本體為 JSON,與 OpenAI 官方規格相同。認證帶 Authorization: Bearer YOUR_API_KEY 標頭(金鑰不可放在網址查詢參數)。

參數型別必填說明
modelstring必填模型代號(例 gpt-5.6-terra)。必須在 GET /v1/models 回傳清單內,否則回 400 與 "No pricing info! Please use other models!"。
messagesarray必填對話訊息陣列,每筆 {"role": "system" | "user" | "assistant", "content": "..."}。
streamboolean選填true 時以 SSE 串流回應(data: {JSON} 逐段,最後 data: [DONE])。
web_search_optionsobject選填啟用網頁搜尋(按次計費)。
max_tokens/temperature/top_p/tools(function calling)等—選填其餘官方參數原樣透傳;hosted 工具(code_interpreter 等)不支援、回 400。

Responses API(POST /v1/responses)改用 input(string 或 array,必填)與 model(必填),可帶 tools: [{"type": "web_search"}] 啟用搜尋;其餘官方參數原樣透傳。

回應格式

非串流:官方 JSON——Chat Completions 的文字在 choices[0].message.content、用量在 usage;Responses 的文字在 output_text/output[]。回應標頭另帶 X-Cost-Points(本次扣點)與 X-Credits-Remaining(扣後餘額)。

串流:SSE 逐段送出,Chat Completions 增量在 choices[0].delta.content,結束為 data: [DONE];串流無法帶扣點標頭,餘額請改查 GET /stu/api/user/get_credits。

串流範例

curl -N https://www.myai168.com/stu/api/openai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.6-terra","stream":true,"messages":[{"role":"user","content":"Hello"}]}'
data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hi"},"index":0}]}

data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{},"finish_reason":"stop","index":0}]}

data: [DONE]

錯誤碼

HTTP 狀態意義
401金鑰缺漏或無效(同 IP 連續失敗會被暫時封鎖)。
402點數不足(請先儲值)。
400請求本體格式錯誤、模型不在支援清單("No pricing info! Please use other models!"),或帶了不支援的 hosted 工具。
502上游供應商錯誤——一律不扣點。

任何錯誤(含供應商未回用量資訊)一律不扣點。

‹ 上一頁:隱私權下一頁:Anthropic Claude API ›
↑

其他常見問題頁面

一般問題

  • 常見問題
  • 帳戶問題
  • 功能問題
  • 隱私權

API 說明文件

  • Anthropic Claude API
  • Google Gemini API
  • Google News API
  • OpenRouter API
  • API 收費

CLI 與 Agent 教學

  • OpenCode
  • OpenClaw
  • Hermes Agent
  • Claude Code CLI
  • Codex CLI

MYAI168 API 與 MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP 網頁及應用程式