POST /stu/api/openai/v1/responsesResponses 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/completionsChat 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 —— 支援,含串流。tools: [{"type": "web_search"}],Chat Completions 用 web_search_options。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 查詢餘額。請求本體為 JSON,與 OpenAI 官方規格相同。認證帶 Authorization: Bearer YOUR_API_KEY 標頭(金鑰不可放在網址查詢參數)。
| 參數 | 型別 | 必填 | 說明 |
|---|---|---|---|
model | string | 必填 | 模型代號(例 gpt-5.6-terra)。必須在 GET /v1/models 回傳清單內,否則回 400 與 "No pricing info! Please use other models!"。 |
messages | array | 必填 | 對話訊息陣列,每筆 {"role": "system" | "user" | "assistant", "content": "..."}。 |
stream | boolean | 選填 | true 時以 SSE 串流回應(data: {JSON} 逐段,最後 data: [DONE])。 |
web_search_options | object | 選填 | 啟用網頁搜尋(按次計費)。 |
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 | 上游供應商錯誤——一律不扣點。 |
任何錯誤(含供應商未回用量資訊)一律不扣點。