跳转到主要内容

Responses Function Calling

POST /v1/responses
截至 2026 年 3 月 23 日,Crazyrouter 生产环境已验证 gpt-5.4 在 Responses API 下可稳定返回 function_call
Claude 当前不支持 POST /v1/responses。如果你需要 Claude 的工具调用,请改用 POST /v1/messagesPOST /v1/chat/completions

第一步:让模型产出函数调用

curl https://crazyrouter.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-5.4",
    "input": "What is the weather in Beijing? Use the tool.",
    "tools": [
      {
        "type": "function",
        "name": "get_weather",
        "description": "Get weather info for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {"type": "string"}
          },
          "required": ["city"],
          "additionalProperties": false
        }
      }
    ]
  }'
生产环境实际响应的关键形态:
{
  "output": [
    {
      "type": "function_call",
      "name": "get_weather",
      "arguments": "{\"city\":\"Beijing\"}"
    }
  ]
}

第二步:回传函数结果

拿到 function_call 之后,把你自己执行函数得到的结果作为 function_call_output 再发回去:
{
  "model": "gpt-5.4",
  "input": [
    {
      "type": "function_call",
      "call_id": "call_123",
      "name": "get_weather",
      "arguments": "{\"city\":\"Beijing\"}"
    },
    {
      "type": "function_call_output",
      "call_id": "call_123",
      "output": "{\"temperature\":22,\"condition\":\"sunny\"}"
    }
  ],
  "tools": [
    {
      "type": "function",
      "name": "get_weather",
      "description": "Get weather info for a city",
      "parameters": {
        "type": "object",
        "properties": {
          "city": {"type": "string"}
        },
        "required": ["city"],
        "additionalProperties": false
      }
    }
  ]
}
当前页面只保留了生产环境已验证成功的 function_call 路径。更复杂的多工具串联或流式参数增量,请在接入前自行再做一次当日生产验证。