> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipellm.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 取消任务

> 取消尚未完成的异步任务。

停止仍处于 `pending` 或 `processing` 的任务。已经进入终态的任务无法取消。

> [!NOTE]
>
> 通过 [`POST /v2/videos`](https://docs.pipellm.ai/zh/api-reference/video/create) 创建的视频，用
> `DELETE /v2/videos/{id}` 取消。

**task\_id** `string` *required*

任务创建时返回的任务 ID。

```bash cURL theme={"dark"}
curl -X POST https://api.pipellm.ai/v1/tasks/gen-1732891234-abc123xyz/cancel \
  -H "Authorization: Bearer $PIPELLM_API_KEY"
```

```json theme={"dark"}
{
  "id": "gen-1732891234-abc123xyz",
  "status": "cancelled",
  "type": "video_generation",
  "model": "seedance-2-0-mini",
  "created_at": "2026-09-17T08:14:02Z"
}
```

响应就是 [`GET /v1/tasks/{task_id}`](https://docs.pipellm.ai/zh/api-reference/tasks/get) 返回的同一个任务对象，
`status` 变为 `cancelled`。

## 计费

取消不退还上游已经完成的那部分算力。视频的报价在任务创建时就锁定了，见
[查询模型定价](https://docs.pipellm.ai/zh/api-reference/model-pricing.md)。

## 错误

错误信封与 [错误与排查](https://docs.pipellm.ai/zh/api-reference/errors.md) 一致。

> [accordion] 404 not\_found
>
> 任务 ID 不存在，或属于其他账户。

> [accordion] 409 invalid\_request\_error
>
> 任务已进入 `completed`、`failed` 或 `cancelled`。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.