GPT Image 2
ID:
openai/gpt-image-2OpenAI 的 GPT Image 2 圖片產生 API — 最高 4K,原生推理能力、多語言文字渲染、參考圖片引導編輯。
文字轉圖片圖片編輯參考圖片商業用途
概覽
OpenAI 的 GPT Image 2 圖片產生 API — 最高 4K,原生推理能力、多語言文字渲染、參考圖片引導編輯。
驗證
所有 API 請求都需要透過 Authorization 標頭以 Bearer 方式傳遞有效的 API 金鑰。
快速開始
憑證
設定 RUNBASE_API_KEY 環境變數。
Shell
export RUNBASE_API_KEY=your-api-key建立執行
Shell
curl -s https://runbase.net/api/v1/runs \
-H "Authorization: Bearer $RUNBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"input": {
"prompt": "A cinematic product photo of a ceramic lamp"
}
}'執行紀錄
執行為非同步處理。提交請求後,輪詢取得結果。
建立執行
Shell
curl -s https://runbase.net/api/v1/runs \
-H "Authorization: Bearer $RUNBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"input": { "prompt": "A cinematic product photo of a ceramic lamp" }
}'取得執行狀態
Shell
curl -s https://runbase.net/api/v1/runs/RUN_ID \
-H "Authorization: Bearer $RUNBASE_API_KEY"取得結果
輪詢狀態端點,直到 status 為 "succeeded",然後從回應中讀取 output.urls。
輸入結構
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| prompt | string | 必填 | Prompt |
| aspect_ratio | string | 選填 | Aspect ratio選項: 1:12:33:23:44:34:55:49:1616:921:9 |
| resolution | string | 選填 | Resolution選項: 1K2K4K |
| image_urls | string[] | 選填 | Reference images |
輸出結構
| 欄位 | 類型 | 說明 |
|---|---|---|
| urls | string[] | 產生的輸出 URL |
錯誤
API 使用標準 HTTP 狀態碼表示成功或失敗。
| 狀態碼 | 說明 |
|---|---|
| 400 | 无效请求 - 参数缺失或格式错误 |
| 401 | 认证失败 - API 密钥缺失或无效 |
| 402 | 额度不足 |
| 403 | 禁止访问 - IP 不在白名单或 API 密钥消费限额已超出 |
| 404 | 未找到运行记录 |
| 429 | 请求频率超限 |
| 500 | 服务器内部错误 |

