跳到正文
土土金API

API 參考

Responses 介面

POST /v1/responses 的請求頭、參數、請求與響應示例和流式事件。格式與 OpenAI Responses API 一致,部分模型只支援這種格式,本站按原格式轉發請求。

POST /v1/responses 是 OpenAI 較新的介面格式:用 input 代替 messages,系統指令單獨放在 instructions 裡,推理強度、結構化輸出和工具的寫法也和 Chat Completions 不同。目錄裡有一部分模型只支援這種格式。本站把請求按原格式轉發給模型服務,參數是否生效以對應模型的官方說明為準。

POSThttps://www.tutujin.com/v1/responses

請求頭

請求頭必填說明
Authorization是Bearer sk-...,控制台建立的 API Key
Content-Type是application/json

請求參數

參數類型必填說明
modelstring是模型名,例如 gpt-6.1-sol
inputstring 或 array是輸入內容。可以是一段文本,也可以是訊息陣列,多輪對話和圖文輸入用陣列,結構見下文
instructionsstring否系統指令,相當於 Chat Completions 裡的 system 訊息
max_output_tokensinteger否本次最多生成多少 tokens,包含推理模型的思考部分
temperaturenumber否取樣溫度,越高越發散。推理模型通常不支援
top_pnumber否核取樣,和 temperature 一般只調一個
streamboolean否設為 true 時以 SSE 事件流返回,預設 false
reasoningobject否推理配置,例如 {"effort": "low"},常見取值 low、medium、high,僅推理模型支援
textobject否輸出格式,例如 {"format": {"type": "json_object"}} 要求輸出 JSON;部分模型支援 json_schema 嚴格結構化輸出
toolsarray否可供模型呼叫的工具,例如函式定義。內建工具能否使用取決於模型
tool_choicestring 或 object否auto、none、required,或指定某個工具
storeboolean否是否在服務端儲存本次響應。本站沒有實測依賴服務端儲存的功能,建議設為 false
previous_response_idstring否引用上一輪響應來延續對話。它依賴服務端儲存的響應,本站未實測,建議在 input 裡自己帶上歷史訊息
metadataobject否自定義鍵值對,方便你這邊對帳和排查

input 結構

最簡單的寫法是直接傳一段字串。多輪對話或圖文輸入時傳陣列,每項是一條訊息:

JSON
[
  { "role": "user", "content": "这张发票的金额是多少?" },
  {
    "role": "user",
    "content": [
      { "type": "input_text", "text": "只回答金额和币种。" },
      { "type": "input_image", "image_url": "https://example.com/invoice.png" }
    ]
  }
]

role 可以是 user、assistant、system 或 developer。圖片也可以用 data:image/png;base64,... 的形式直接放進 image_url。

請求示例

curl https://www.tutujin.com/v1/responses \
  -H "Authorization: Bearer $TUTUJIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.1-sol",
    "instructions": "你是财务助理,回答简洁,金额保留两位小数。",
    "input": "差旅费 1280 元,餐补每天 80 元共 3 天,合计报销多少?"
  }'

響應示例

JSON
{
  "id": "resp_...",
  "object": "response",
  "created_at": 1794000000,
  "status": "completed",
  "model": "gpt-6.1-sol",
  "output": [
    {
      "type": "message",
      "id": "msg_...",
      "status": "completed",
      "role": "assistant",
      "content": [
        { "type": "output_text", "text": "合计报销 1520.00 元。", "annotations": [] }
      ]
    }
  ],
  "usage": {
    "input_tokens": 48,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 15,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 63
  }
}
欄位說明
statuscompleted 表示正常完成;incomplete 通常是達到 max_output_tokens 被截斷
output輸出項陣列,可能包含 message(回答)、reasoning(推理摘要)、function_call(需要你執行的函式呼叫)
output[].content[].text回答文本。官方 SDK 提供 output_text 屬性,直接拼好了全部文本
usage.input_tokens輸入 tokens,按輸入單價計費
usage.input_tokens_details.cached_tokens命中上下文快取的輸入 tokens,按快取讀取價計費
usage.output_tokens輸出 tokens,按輸出單價計費,其中 reasoning_tokens 是思考部分

流式輸出

設定 "stream": true 後,服務端按 Server-Sent Events 逐個推送事件。每個事件有 event: 名稱,文本增量在 response.output_text.delta 事件的 delta 欄位裡,response.completed 事件帶有完整響應和用量:

Text
event: response.created
data: {"type":"response.created","response":{"id":"resp_...","status":"in_progress"}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","output_index":0,"content_index":0,"delta":"合计"}

event: response.output_text.done
data: {"type":"response.output_text.done","output_index":0,"content_index":0,"text":"合计报销 1520.00 元。"}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_...","status":"completed","usage":{"input_tokens":48,"output_tokens":15,"total_tokens":63}}}

用 SDK 時按事件類型取文本:

stream = client.responses.create(
    model="gpt-6.1-sol",
    input="写一段 100 字的产品介绍",
    stream=True,
)
for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
    elif event.type == "response.completed":
        print("\n", event.response.usage)

注意事項

  • 這個介面是原樣轉發,沒有在本站單獨實測。接入新模型時先用小流量驗證參數和返回結構。
  • 多輪對話請在 input 裡帶上完整的歷史訊息,不要依賴 previous_response_id 和 store。
  • 推理模型的思考 tokens 計入輸出,費用可能明顯高於普通模型,可以用 max_output_tokens 和 reasoning.effort 控制。
  • 聯網搜尋等內建工具是否可用、是否另行計費都取決於模型,以控制台「操作日誌」為準。
  • 如果模型同時支援 Chat Completions,又不需要 Responses 的專有功能,用 Chat Completions 更省事,切換其他廠商的模型也只需改 model。

支援此介面的模型

模型廠商最低價分組輸入 ¥/百萬輸出 ¥/百萬按次 ¥/次
GPT-6.1 SolOpenAI標準¥4¥20—
GPT-6 LunaOpenAI標準¥0.2¥1—
GPT-6 SolOpenAI標準¥20¥100—
gpt-6-astraOpenAI標準¥20¥100—
muse-wonder-1.0其他標準¥56¥280—

價格為人民幣,取各模型最低價分組;價格更新於 2026年11月13日 下午6:08。

沒找到答案?加客服微信 JsnonoChat,傳送報錯資訊裡的 request id,我們幫你排查。