跳轉到主要內容
POST
/
v1
/
responses
curl -X POST https://qingbo.dev/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5",
    "input": "解释一下冒泡排序算法。"
  }'
{
  "id": "resp_09e342953eda0be6006905acbcvoik1nhmezpmzzl7lex552vq",
  "object": "response",
  "created_at": 1761979488,
  "model": "gpt-5-2025-08-07",
  "status": "completed",
  "output": [
    {
      "id": "rs_09e342953eda0be6006905ac62b6f48197aefa292b7dcdd477",
      "type": "reasoning",
      "summary": []
    },
    {
      "id": "msg_09e342953eda0be6006905ac649e0081979f9859a09c70d4db",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "一幅温暖的插画:一只灰色虎斑猫正抱着一只带红色围巾的水獭,两只动物都闭着眼微笑,呈现亲密友好的场景。",
          "annotations": [],
          "logprobs": []
        }
      ]
  }
],
"usage": {
    "input_tokens": 642,
    "output_tokens": 184,
    "total_tokens": 826,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens_details": {
      "reasoning_tokens": 128
    }
  },
  "reasoning": {
    "effort": "medium",
    "summary": null
  },
  "temperature": 1,
  "top_p": 1,
  "tool_choice": "auto",
  "tools": [],
  "parallel_tool_calls": true,
  "store": true,
  "service_tier": "default",
  "truncation": "disabled",
  "background": false,
  "content_filters": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "metadata": {},
  "previous_response_id": null,
  "prompt_cache_key": null,
  "safety_identifier": null,
  "text": {
    "format": {
      "type": "text"
    },
    "verbosity": "medium"
  },
  "top_logprobs": 0,
  "user": null
}
  • 完全相容 OpenAI Responses API 格式
  • 支援文字和圖像的多模態輸入
  • 支援工具擴充:網路搜尋、檔案搜尋、函式呼叫、遠端 MCP
curl -X POST https://qingbo.dev/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5",
    "input": "解释一下冒泡排序算法。"
  }'
{
  "id": "resp_09e342953eda0be6006905acbcvoik1nhmezpmzzl7lex552vq",
  "object": "response",
  "created_at": 1761979488,
  "model": "gpt-5-2025-08-07",
  "status": "completed",
  "output": [
    {
      "id": "rs_09e342953eda0be6006905ac62b6f48197aefa292b7dcdd477",
      "type": "reasoning",
      "summary": []
    },
    {
      "id": "msg_09e342953eda0be6006905ac649e0081979f9859a09c70d4db",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "一幅温暖的插画:一只灰色虎斑猫正抱着一只带红色围巾的水獭,两只动物都闭着眼微笑,呈现亲密友好的场景。",
          "annotations": [],
          "logprobs": []
        }
      ]
  }
],
"usage": {
    "input_tokens": 642,
    "output_tokens": 184,
    "total_tokens": 826,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens_details": {
      "reasoning_tokens": 128
    }
  },
  "reasoning": {
    "effort": "medium",
    "summary": null
  },
  "temperature": 1,
  "top_p": 1,
  "tool_choice": "auto",
  "tools": [],
  "parallel_tool_calls": true,
  "store": true,
  "service_tier": "default",
  "truncation": "disabled",
  "background": false,
  "content_filters": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "metadata": {},
  "previous_response_id": null,
  "prompt_cache_key": null,
  "safety_identifier": null,
  "text": {
    "format": {
      "type": "text"
    },
    "verbosity": "medium"
  },
  "top_logprobs": 0,
  "user": null
}

Authorizations

Authorization
string
必填
所有介面均需要使用 Bearer Token 進行認證取得 API Key:存取 API Key 管理頁面 取得您的 API Key使用時在請求標頭中新增:
Authorization: Bearer YOUR_API_KEY

Body

model
string
必填
模型名稱支援的模型包括:
  • gpt-5 - OpenAI 最新多模態模型
  • gpt-4o - GPT-4 最佳化版多模態模型
  • gpt-4-vision - GPT-4 視覺理解模型
  • 更多模型持續更新中…
input
string or array
必填
輸入內容,支援字串或訊息陣列字串形式為簡單文字輸入,陣列形式支援多輪對話和多模態:
tools
array
工具列表,可選配置支援的工具類型:
  • web_search - 網路搜尋
  • file_search - 檔案搜尋
  • function - 函式呼叫
  • remote_mcp - 遠端 MCP 服務
temperature
number
控制輸出隨機性,範圍 0-2預設值:1.0
max_tokens
integer
生成的最大 token 數量
stream
boolean
是否使用串流輸出預設值:false

Response

id
string
回應的唯一識別碼
object
string
物件類型,固定為 response
created_at
integer
建立時間戳
model
string
實際使用的模型名稱(如 gpt-5-2025-08-07
status
string
回應狀態可能的值:
  • completed - 已完成
  • in_progress - 處理中
  • failed - 失敗
  • cancelled - 已取消
output
array
輸出內容陣列
usage
object
token 使用統計
reasoning
object
推理配置資訊(思考模型專用)
temperature
number
實際使用的取樣溫度
top_p
number
實際使用的核取樣參數
tool_choice
string
工具選擇策略
tools
array
使用的工具列表
parallel_tool_calls
boolean
是否允許並行工具呼叫
store
boolean
是否儲存對話歷史
service_tier
string
服務等級
truncation
string
截斷策略
text
object
文字格式配置
background
boolean
是否為背景任務
error
object
錯誤資訊(如果有)
metadata
object
中繼資料資訊

使用範例

圖片分析

{
  "model": "gpt-5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "这张图片里有什么?请详细描述"
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/image.jpg"
        }
      ]
    }
  ]
}

影片分析

{
  "model": "gemini-2.5-pro",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "分析一下这个视频的内容"
        },
        {
          "type": "input_video",
          "video_url": "https://example.com/video.mp4"
        }
      ]
    }
  ],
  "max_tokens": 5000
}

使用網路搜尋工具

{
  "model": "gpt-5",
  "tools": [
    {"type": "web_search"}
  ],
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "2025年最新的AI技术趋势是什么?"
        }
      ]
    }
  ]
}

使用函式呼叫

{
  "model": "gpt-5",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "獲取城市天氣資訊",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string",
              "description": "城市名稱,例如:北京"
            }
          },
          "required": ["city"]
        }
      }
    }
  ],
  "input": "北京今天天气怎么样?"
}

內容類型說明

input_text

文字輸入類型 屬性:
  • type: 固定為 "input_text"
  • text: 文字內容(字串)

input_image

圖像輸入類型 屬性:
  • type: 固定為 "input_image"
  • image_url: 圖像 URL 或 Base64 編碼的資料 URI
支援的圖像格式:
  • JPEG
  • PNG
  • GIF
  • WebP
圖像大小限制:
  • 最大檔案大小:20MB
  • 建議解析度:不超過 2048x2048 像素

input_video

影片輸入類型(部分模型支援) 屬性:
  • type: 固定為 "input_video"
  • video_url: 影片 URL
支援的影片格式:
  • MP4
  • MOV
  • AVI
  • WebM
影片大小限制:
  • 最大檔案大小:200MB
  • 最大時長:10 分鐘
  • 建議解析度:1080p

工具使用詳解

使用網路搜尋工具可以讓模型存取即時網際網路資訊。 配置範例:
{
  "tools": [{"type": "web_search"}]
}
適用場景:
  • 查詢最新新聞和時事
  • 取得即時資料(股票、天氣、匯率等)
  • 搜尋最新的技術文件和資料
  • 驗證事實資訊
檔案搜尋工具允許模型在已上傳的文件中搜尋相關資訊。 配置範例:
{
  "tools": [{"type": "file_search"}]
}
適用場景:
  • 分析企業內部文件
  • 搜尋技術規範和手冊
  • 查詢合約和法律文件
  • 知識庫問答系統

函式呼叫 (Function Calling)

定義自訂函式,讓模型能夠呼叫外部 API 或執行特定操作。 完整配置範例:
{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_stock_price",
        "description": "獲取股票的即時價格",
        "parameters": {
          "type": "object",
          "properties": {
            "symbol": {
              "type": "string",
              "description": "股票代碼,例如:AAPL"
            },
            "currency": {
              "type": "string",
              "enum": ["USD", "CNY"],
              "description": "貨幣單位",
              "default": "USD"
            }
          },
          "required": ["symbol"]
        }
      }
    }
  ]
}
參數說明:
  • name: 函式名稱(必需)
  • description: 函式功能描述(必需)
  • parameters: 參數定義,使用 JSON Schema 格式
    • type: 參數類型
    • properties: 參數屬性定義
    • required: 必需參數列表
適用場景:
  • 呼叫第三方 API
  • 執行資料庫查詢
  • 觸發業務流程
  • 與內部系統整合

遠端 MCP (Remote MCP)

連線到遠端模型上下文協定(MCP)服務,擴充模型能力。 配置範例:
{
  "tools": [
    {
      "type": "remote_mcp",
      "remote_mcp": {
        "url": "https://your-mcp-server.com/api",
        "auth_token": "your_auth_token",
        "timeout": 30
      }
    }
  ]
}
參數說明:
  • url: MCP 伺服器位址(必需)
  • auth_token: 認證權杖(可選)
  • timeout: 逾時時間(秒),預設 30 秒
適用場景:
  • 連線企業級 AI 服務
  • 使用專業領域模型
  • 存取受保護的資料來源
  • 分散式 AI 系統整合

工具回應格式

當模型使用工具時,回應格式會包含工具呼叫資訊:
{
  "id": "resp-123456",
  "object": "response",
  "created": 1677652288,
  "model": "gpt-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_abc123",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"city\": \"北京\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ]
}
工具呼叫流程:
  1. 模型接收使用者輸入
  2. 分析是否需要使用工具
  3. 如需要,回傳工具呼叫請求
  4. 用戶端執行工具呼叫
  5. 將工具結果回傳給模型
  6. 模型生成最終回應

注意事項

  1. 圖像 URL 要求
    • 必須是公開可存取的 URL
    • 或使用 Base64 編碼的 Data URI 格式
  2. Token 計費
    • 圖像會根據其解析度消耗相應的 tokens
    • 高解析度圖像會自動調整大小以最佳化成本
    • 工具呼叫也會消耗額外的 tokens
  3. 內容順序
    • content 陣列中的元素順序會影響模型理解
    • 建議先放置文字指令,再放置圖像/影片
  4. 多模態組合
    • 可以在一個請求中混合多個文字和圖像
    • 支援多輪對話,保持上下文連貫性
  5. 工具使用限制
    • 同時使用多個工具時,模型會智慧選擇最合適的工具
    • 函式呼叫需要明確的函式定義和參數說明
    • 網路搜尋結果可能受地域和時間限制
  6. API 相容性
    • 完全相容 OpenAI Responses API 格式
    • 可無縫遷移現有 OpenAI 程式碼
    • 支援所有 OpenAI 工具擴充功能