Cancel a run

POSThttps:/api.openai.com/v1/threads/{thread_id}/runs/{run_id}/cancel

Cancels a run that is in_progress.

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 to cancel.

Response

The modified run object matching the specified ID.

Example request
1
curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel \
2
-H "Authorization: Bearer $OPENAI_API_KEY" \
3
-H "OpenAI-Beta: assistants=v2" \
4
-X POST
Example response
1
{
2
"id": "run_abc123",
3
"object": "thread.run",
4
"created_at": 1699076126,
5
"assistant_id": "asst_abc123",
6
"thread_id": "thread_abc123",
7
"status": "cancelling",
8
"started_at": 1699076126,
9
"expires_at": 1699076726,
10
"cancelled_at": null,
11
"failed_at": null,
12
"completed_at": null,
13
"last_error": null,
14
"model": "gpt-4o",
15
"instructions": "You summarize books.",
16
"tools": [
17
{
18
"type": "file_search"
19
}
20
],
21
"tool_resources": {
22
"file_search": {
23
"vector_store_ids": ["vs_123"]
24
}
25
},
26
"metadata": {},
27
"usage": null,
28
"temperature": 1.0,
29
"top_p": 1.0,
30
"response_format": "auto",
31
"tool_choice": "auto",
32
"parallel_tool_calls": true
33
}
Built with