API Hop 文件
OpenAI 多模態回應
OpenAI 相容的 Responses API。此端點使用 OpenAI 風格的 `input`,支援文字、公開圖像網址、PDF 檔案輸入、工具呼叫、推理選項與串流參數。
https://api.apihop.ai/openai/responsesOpenAI 相容的 Responses API。此端點使用 OpenAI 風格的 input,支援文字、公開圖像網址、PDF 檔案輸入、工具呼叫、推理選項與串流參數。
POST https://api.apihop.ai/openai/responses驗證
所有請求均需要 Bearer Token 驗證。
Authorization: Bearer YOUR_API_KEY請求主體
modelstring必填預設: gpt-5.4目前已啟用且支援 Responses 的模型:
gpt-5.4gpt-5.5gpt-5.6-solgpt-5.6-terragpt-6-astra
目前 API 金鑰可見的模型,請見模型目錄。
inputstring | object[]輸入內容。除非提供非空的 previous_response_id,否則必填。兩個欄位均省略或輸入類型無效時,會在計費前回傳 400。
支援形式:
- 字串,相當於一則
user文字輸入。 - 輸入項目陣列,用於對話歷程、多模態輸入與工具呼叫結果。
輸入陣列中的每個物件可包含以下欄位:
typestring輸入項目類型。
常見值:
message:訊息輸入。function_call_output:函式工具呼叫的結果。
rolestringtype=message 時的角色。
常見值:
developersystemuserassistant
contentstring | object[]訊息內容。
多模態請求請使用內容區塊陣列。內容區塊支援:
typestring內容區塊類型。
目前支援:
input_textinput_imageinput_file
textstringtype=input_text 時的文字內容。
image_urlstringtype=input_image 時的公開圖像網址。
僅支援可公開存取的 http:// 或 https:// 圖像網址。不支援像 data:image/...;base64,... 這樣的 Base64 資料網址。
detailstring預設: autotype=input_image 時的圖像細節層級。
常見值:
autolowhigh
file_datastringtype=input_file 時的檔案內容資料網址。PDF 可使用 data:application/pdf;base64,...。
filenamestringtype=input_file 時的檔案名稱。
instructionsstring插入模型上下文的系統或開發者指示。
max_output_tokensinteger選填的最大輸出 token,必須為正整數。省略此欄位會使用所選模型的上游預設值。依模型而定,預算可能包含推理 token 與最終文字。預算過小可能截斷答案,或在產生最終文字前耗盡;提高預算可能增加費用。
streamboolean預設: false是否串流回應。
false:傳回完整回應true:傳回 OpenAI Responses 風格的 SSE 事件
temperaturenumber預設: 1.0取樣溫度,通常介於 0 至 2。
top_pnumber預設: 1.0核心取樣參數,通常介於 0 至 1。
textobject文字輸出設定。
text.formatobject文字格式設定,例如 { "type": "text" } 或 JSON schema。
text.verbositystring輸出詳盡程度,例如 low、medium 或 high。是否支援取決於所選模型。
toolsobject[]工具定義。可用性取決於所選模型與可用功能。
tool_choicestring | object工具選擇策略。
parallel_tool_callsboolean是否允許平行工具呼叫。
reasoningobject推理相關選項。
includestring[]要包含在回應中的額外欄位。
prompt_cache_keystring用於重用提示詞快取的快取鍵。
prompt_cache_retentionstring提示詞快取保留策略。支援的值取決於所選模型與可用功能。
safety_identifierstring用於安全控制的穩定終端使用者識別碼。
storeboolean是否允許儲存回應狀態。
模型參數差異
- 原生 OpenAI 相容 Responses 轉送會在上游請求中保留
top_p;驗證與取樣行為取決於所選模型及上游。2026-09-26 的檢查接受gpt-5.5、gpt-5.6-sol與gpt-5.6-terra的top_p: 0.9。接受與轉送不代表有取樣效果,也不保證其他值、模型或之後請求受支援。請從最小請求開始。 - 本頁的支援範圍僅適用於一般
/openai/responses端點,不代表同一模型支援/openai/responses/compact、WebSocket 或具狀態的previous_response_id。 - 上述五個 GPT 模型目前沒有經驗證的 Compact 通道。若無明確啟用的通道,Compact 請求會在計費前遭拒。一般 Responses 與 Responses WebSocket 仍可使用。
請求範例
以下範例均提供 input。接續請求若提供有效的 previous_response_id,且所選通道支援具狀態接續,則可省略 input。回應 ID 不會在不支援的通道上啟用此能力。工具結果仍是有效輸入項目,包含 function_call_output。
文字
{
"model": "gpt-5.4",
"input": "Hello, introduce yourself in one sentence."
}Codex CLI 風格參數
{
"model": "gpt-5.5",
"input": "Reply with READY only.",
"reasoning": {
"effort": "xhigh"
},
"store": false,
"text": {
"verbosity": "low"
},
"stream": true
}圖像理解
{
"model": "gpt-5.4",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "What is in this image?"
},
{
"type": "input_image",
"image_url": "https://example.com/cat.png",
"detail": "high"
}
]
}
]
}檔案輸入
使用 file_data 加上 filename 提交 PDF 內容。file_data 必須是完整資料網址。
{
"model": "gpt-5.4",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Summarize the key points in this PDF."
},
{
"type": "input_file",
"file_data": "data:application/pdf;base64,JVBERi0xLjQKJc...",
"filename": "report.pdf"
}
]
}
]
}圖像與檔案輸入
{
"model": "gpt-5.4",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Give three conclusions based on the image and attachment."
},
{
"type": "input_image",
"image_url": "https://example.com/chart.png",
"detail": "high"
},
{
"type": "input_file",
"file_data": "data:application/pdf;base64,JVBERi0xLjQKJc...",
"filename": "notes.pdf"
}
]
}
]
}串流輸出
{
"model": "gpt-5.4",
"stream": true,
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Explain this diagram step by step."
},
{
"type": "input_image",
"image_url": "https://example.com/diagram.png"
}
]
}
]
}回應
非串流回應遵循 OpenAI Responses 風格。實際欄位可能隨所選模型能力而異。
idstring回應的唯一識別碼。
objectstring回應物件類型,通常為 response。
created_atinteger建立時間戳記。
modelstring實際使用的模型。
outputobject[]輸出項目列表。常見項目包含 message、function_call 及工具相關輸出。
usageobjectToken 用量統計,例如 input_tokens、output_tokens 與 total_tokens。
成功範例
{
"id": "resp_123",
"object": "response",
"created_at": 1766534400,
"model": "gpt-5.4",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"text": "The image shows a cat, and the attachment is a document about pet care."
}
]
}
],
"usage": {
"input_tokens": 128,
"output_tokens": 42,
"total_tokens": 170
}
}串流回應
設定 stream=true 時,端點會傳回 Server-Sent Events。
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"The image"}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_123"}}持續讀取事件,直到 response.completed 或連線關閉。
錯誤回應
完整代碼參考、協定差異及診斷步驟,請見錯誤代碼與疑難排解。
平台產生的 HTTP 錯誤使用下列扁平欄位,而非 error 包裝。部分上游錯誤可能保留原始結構;已開始的 SSE 串流內錯誤不遵循此 HTTP 回應範例。
{
"code": 40000,
"message": "Insufficient credit. Required: 30000, Available: 20000",
"type": "api_error"
}注意事項
Responses端點使用input,而非messages。若客戶端只傳送messages,請使用/openai/v1/chat/completions。- 圖像輸入使用
input_image;image_url必須是公開的http://或https://網址。圖像不支援 Base64 資料網址。 - 檔案輸入使用
input_file。PDF 請使用file_data加上filename,file_data應為完整的data:application/pdf;base64,...網址。 - 音訊輸入/輸出、圖像生成工具、檔案搜尋及其他進階能力,取決於所選模型與可用功能。
- 本頁所列欄位構成目前公開的 Responses 請求契約,請勿假設未列出的欄位可用。
/openai/responses是建議的公開路徑。/v1/responses遵循相同的公開請求與回應契約。/compat/v1/responses遵循相同的公開請求與回應契約。/openai/v1/responses遵循相同的公開請求與回應契約。