Cancel one or more runs.
Can cancel runs by thread ID and run IDs, or by status filter.
cancel_many(
self,
*,
thread_id: str | None = None,
run_ids: Sequence[str] | None = None,
status: BulkCancelRunsStatus | None = None,
action: CancelAction = 'interrupt',
headers: Mapping[str, str] | None = None,
params: QueryParamTypes | None = None
) -> Noneclient = get_client(url="http://localhost:2024")
# Cancel all pending runs
await client.runs.cancel_many(status="pending")
# Cancel specific runs on a thread
await client.runs.cancel_many(
thread_id="my_thread_id",
run_ids=["run_1", "run_2"],
action="rollback",
)| Name | Type | Description |
|---|---|---|
thread_id | str | None | Default: NoneThe ID of the thread containing runs to cancel. |
run_ids | Sequence[str] | None | Default: NoneList of run IDs to cancel. |
status | BulkCancelRunsStatus | None | Default: NoneFilter runs by status to cancel. Must be one of
|
action | CancelAction | Default: 'interrupt'Action to take when cancelling the run. Possible values
are |
headers | Mapping[str, str] | None | Default: NoneOptional custom headers to include with the request. |
params | QueryParamTypes | None | Default: NoneOptional query parameters to include with the request. |