Submit tool outputs to run
POSThttps:/api.openai.com/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs
When a run has the status: "requires_action"
and required_action.type
is submit_tool_outputs
, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
Path parameters
thread_id
string
Required
The ID of the thread to which this run belongs.
run_id
string
Required
The ID of the run that requires the tool output submission.
Request body
tool_outputs
array
Required
A list of tools for which the outputs are being submitted.items
object
tool_call_id
string
The ID of the tool call in the
required_action
object within the run object the output is being submitted for.output
string
The output of the tool call to be submitted to continue the run.
stream
boolean or null
If
true
, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with adata: [DONE]
message.
Response
The modified run object matching the specified ID.
Example request
1 curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \2 -H "Authorization: Bearer $OPENAI_API_KEY" \3 -H "Content-Type: application/json" \4 -H "OpenAI-Beta: assistants=v2" \5 -d '{6 "tool_outputs": [7 {8 "tool_call_id": "call_001",9 "output": "70 degrees and sunny."10 }11 ]12 }'
Example response
1 {2 "id": "run_123",3 "object": "thread.run",4 "created_at": 1699075592,5 "assistant_id": "asst_123",6 "thread_id": "thread_123",7 "status": "queued",8 "started_at": 1699075592,9 "expires_at": 1699076192,10 "cancelled_at": null,11 "failed_at": null,12 "completed_at": null,13 "last_error": null,14 "model": "gpt-4o",15 "instructions": null,16 "tools": [17 {18 "type": "function",19 "function": {20 "name": "get_current_weather",21 "description": "Get the current weather in a given location",22 "parameters": {23 "type": "object",24 "properties": {25 "location": {26 "type": "string",27 "description": "The city and state, e.g. San Francisco, CA"28 },29 "unit": {30 "type": "string",31 "enum": ["celsius", "fahrenheit"]32 }33 },34 "required": ["location"]35 }36 }37 }38 ],39 "metadata": {},40 "usage": null,41 "temperature": 1.0,42 "top_p": 1.0,43 "max_prompt_tokens": 1000,44 "max_completion_tokens": 1000,45 "truncation_strategy": {46 "type": "auto",47 "last_messages": null48 },49 "response_format": "auto",50 "tool_choice": "auto",51 "parallel_tool_calls": true52 }
Built with