Skip to main content
Runs

提交工具输出

在运行需要执行工具调用时提交工具输出并继续执行任务。

POST
/threads/{thread_id}/runs/{run_id}/submit_tool_outputs
cURL
curl --request POST \
  --url 'https://dashscope.aliyuncs.com/api/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "tool_outputs": [
    {
      "tool_call_id": "",
      "output": "rain"
    }
  ]
}
'
{
  "id": "run_99935dbd-e731-4bad-b450-60d9d6bf9a44",
  "object": "thread.run",
  "created_at": 1711519089921,
  "thread_id": "thread_9157dfad-71fd-4add-b7a9-1afa452d2d67",
  "assistant_id": "asst_ce66cfa8-b2f8-4e4c-8e17-2c335145be42",
  "status": "in_progress",
  "required_action": {
    "type": "submit_tool_outputs",
    "submit_tool_outputs": {
      "tool_calls": [
        {
          "function": {
            "name": "get_current_weather",
            "arguments": "{\"location\": \"西安\"}"
          },
          "id": "",
          "type": "function"
        }
      ]
    }
  },
  "last_error": {},
  "expires_at": 0,
  "started_at": 0,
  "cancelled_at": 0,
  "failed_at": 0,
  "completed_at": 0,
  "model": "qwen-max",
  "instructions": "你是一个智能小助手,你可以根据用户的需求去调用不同的工具,进而给出回答。请酌情使用工具。",
  "tools": [
    {
      "type": "text_to_image"
    },
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            },
            "unit": {
              "type": "string",
              "enum": [
                "celsius",
                "fahrenheit"
              ]
            }
          },
          "required": [
            "location"
          ]
        }
      }
    }
  ],
  "metadata": {},
  "usage": null,
  "request_id": "792c29a2-e771-9840-9d99-df4f892badd0"
}

Authorizations

string
header
required

DashScope API Key,在控制台 API Key 页面(https://bailian.console.aliyun.com/settings/apikey)获取。请求头格式:Authorization: Bearer $DASHSCOPE_API_KEY。

Path Parameters

string
required

待修改的 thread ID。

string
required

待修改的 run ID。

Body

application/json
object[]
required

待返回给 Assistant 的工具调用结果列表。

boolean

是否流式返回。

Response

200-application/json
Managed Agent API
Flow Agent API
RAG API
Connector API
框架集成
  • 框架