BazaarLinkBazaarLink
登入
文件API 參考SDK 參考Agent 應用AI Skills
Responses API

建立回應

以 OpenAI Responses API 的請求格式(input/instructions)取得模型回應,內部轉換成 Chat Completions 格式後路由到任何支援的模型——這是一層轉譯,不是獨立的推理路徑。這是無狀態端點:傳 store: true 或非 null 的 previous_response_id 會直接回 400(見下方 400 說明的專屬錯誤格式),每次呼叫都要在 input 帶完整的對話內容。串流時,推理過程會以 response.reasoning_text.delta 事件與 type:"reasoning" 的 output item 呈現。

POST/v1/responses

驗證

Authorization必填
string · header

在 Authorization 標頭以 Bearer token 傳入 API 金鑰。

Body

model必填
string

要使用的模型,供應商前綴格式,例如 "openai/gpt-5.4"。

minLength: 1
Example: "openai/gpt-5.4"
input必填
string | InputItem[]

對話輸入——單一字串,或結構化項目陣列(message/function_call/function_call_output)。訊息可用文字或含 input_image 的內容區塊陣列。

instructions
string

系統層級指示,轉換時會作為第一則 system 訊息插入 messages 陣列最前面。

stream
boolean

true 時以 Responses API 的 SSE 事件串流回應(response.created、response.output_item.added、response.output_text.delta、response.reasoning_text.delta、response.completed 等);省略或 false 為一次性 JSON 回應。

max_output_tokens
integer

回應可生成的最大 token 數(轉換為上游 Chat Completions 的 max_tokens)。

tools
Tool[]

模型可呼叫的工具/函式定義清單。接受 Responses 規格的扁平格式 {type:"function", name, description, parameters}(建議用法),也接受 Chat Completions 的巢狀格式 {type:"function", function:{...}}(向後相容,原樣放行)。回應物件裡的 tools 欄位會回顯這裡實際傳入的值。

tool_choice
string | object

控制模型是否/如何被強制呼叫工具,例如 {type:"function", name:"..."}(扁平格式,建議用法,自動轉換給上游)或 "auto"。回應物件裡的 tool_choice 欄位會回顯這裡實際傳入的值,省略時預設 "auto"。

parallel_tool_calls
boolean

有提供 tools 時,是否允許並行工具呼叫。省略時預設 true;回應物件裡的 parallel_tool_calls 欄位會回顯這裡實際傳入的值。

plugins
object[]

外掛陣列(例如 {id:"web"} 啟用網頁搜尋)。僅部分模型路由支援,其他情況無效;:online 會在支援的路由上啟用網頁搜尋。plugins、:online 或 web_search_options 可能產生上游附加費,由請求使用的金鑰承擔:平台金鑰由 BazaarLink 支付上游費用,BYOK 則由你的供應商金鑰支付。

store
boolean

⚠️ 這個端點是無狀態的——傳 true 會直接回 400,不會被接受或忽略。省略或傳 false 才是唯一合法用法。

previous_response_id
string

⚠️ 這個端點是無狀態的——傳任何非 null 值都會直接回 400,不會被接受或忽略。要延續對話,請把完整歷史記錄放進 input 陣列一起送出。

models
string[]

備援模型清單——依序嘗試,主要模型的候選群全部失敗時才會用到。每個備援模型都由 BazaarLink 自行路由,並依該模型的 BazaarLink 客戶價格計費;此清單不會轉發給上游。

reasoning
object

推理模型的思考控制物件(例如 {effort, max_tokens}),原樣轉發給上游,不注入預設值。

reasoning_effort
string

reasoning.effort 的簡寫平面欄位。

lowmediumhigh
thinking
object

Claude 擴展思考的加成 token 預算(例如 {type:"enabled", budget_tokens:2048}),疊加在 max_output_tokens 之上,原樣轉發不注入預設值。

enable_thinking
boolean

Qwen3 / GLM 系列的思考開關,原樣轉發使用者的選擇。

POST /v1/responses
curl https://api.bazaarlink.ai/v1/responses \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4",
    "input": "What is the capital of France?"
  }'
回應範例

BazaarLink 回傳標準化回應並移除上游專屬欄位。usage.cost 是此請求向客戶收取的美元金額。 使用回應 id 或 x-request-id 標頭中的不透明 BazaarLink 請求 ID 呼叫 GET /v1/generation;非串流回應也會在 x-generation-id 提供此 ID。統計資料可能延遲數秒;若收到 404,請短暫重試。 較長的非串流 Chat、Messages 與 Responses 請求(約 12 秒以上)可能在 JSON 本文前包含空白 keep-alive 填充;標準 JSON 解析器可處理開頭空白。

{
  "id": "85e6f35c71a31f19-SJC",
  "object": "response",
  "created_at": 1753500000,
  "completed_at": 1753500002,
  "status": "completed",
  "model": "openai/gpt-5.4",
  "output": [
    {
      "type": "reasoning",
      "id": "bazaarlink-reasoning-item-id",
      "status": "completed",
      "summary": [],
      "content": [
        {
          "type": "reasoning_text",
          "text": "The user is asking a simple geography fact..."
        }
      ]
    },
    {
      "type": "message",
      "id": "bazaarlink-message-item-id",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "The capital of France is Paris.",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 14,
    "output_tokens": 32,
    "total_tokens": 46,
    "cost": 0.00021,
    "bz_cost": 0.00021,
    "output_tokens_details": {
      "reasoning_tokens": 18
    }
  },
  "error": null,
  "incomplete_details": null,
  "tool_choice": "auto",
  "tools": [],
  "truncation": "auto",
  "parallel_tool_calls": true,
  "metadata": {},
  "store": false
}
客服
客服
您好!有什麼可以協助?
請留下訊息,我們會盡快回覆。
建立回應 — BazaarLink API