---
title: 取消 Batch | RunAPI
description: 请求执行方取消尚未终态的 Batch。
url: https://runapi.ai/zh-CN/docs/api/protocol/batches/cancel.md
canonical: https://runapi.ai/zh-CN/docs/api/protocol/batches/cancel
locale: zh-CN
---

> HTML version: https://runapi.ai/zh-CN/docs/api/protocol/batches/cancel
> Site index for agents: https://runapi.ai/llms.txt

# 取消 Batch

请求执行方取消尚未终态的 Batch。

## 端点

POST /v1/batches/:batch_id/cancel

基础 URL: https://runapi.ai

API 版本: v1

身份验证: Authorization: Bearer YOUR_API_KEY

## 请求

只能在列出的请求位置发送值。

### 路径参数

```json
{
  "batch_id": {
    "description": "RunAPI Batch ID.",
    "required": true,
    "type": "string"
  }
}
```

## 成功响应

HTTP 200 - POST /v1/batches/:batch_id/cancel

```json
{
  "cancelling_at": 1785197000,
  "completion_window": "24h",
  "created_at": 1785196800,
  "endpoint": "/v1/moderations",
  "id": "batch_abc123",
  "input_file_id": "file_batch123",
  "metadata": {
    "customer_tag": "demo"
  },
  "object": "batch",
  "request_counts": {
    "completed": 1,
    "failed": 0,
    "total": 3
  },
  "status": "cancelling"
}
```

## 错误响应 (401)

HTTP 401

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "authentication_error",
    "message": "Missing API key",
    "param": null,
    "type": "authentication_error"
  }
}
```

## 错误响应 (400)

HTTP 400

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "invalid_request_error",
    "message": "Malformed request",
    "param": null,
    "type": "invalid_request_error"
  }
}
```

## 错误响应 (404)

HTTP 404

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "not_found",
    "message": "File not found",
    "param": null,
    "type": "invalid_request_error"
  }
}
```

## 错误响应 (409)

HTTP 409

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "upload_state_conflict",
    "message": "Upload state conflict",
    "param": null,
    "type": "invalid_request_error"
  }
}
```

## 错误响应 (402)

HTTP 402

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "payment_required",
    "message": "Insufficient balance",
    "param": null,
    "type": "insufficient_balance"
  }
}
```

## 错误响应 (422)

HTTP 422

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "invalid_upload",
    "message": "Upload request rejected",
    "param": null,
    "type": "invalid_request_error"
  }
}
```

## 错误响应 (502)

HTTP 502

### 响应 Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### 响应示例

```json
{
  "error": {
    "code": "storage_write_failed",
    "message": "File storage failed",
    "param": null,
    "type": "server_error"
  }
}
```

## cURL 示例



### curl

```curl
curl -X POST https://runapi.ai/v1/batches/batch_abc123/cancel \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

## 相关参考

- [Batch](https://runapi.ai/docs/api/protocol/batches.md)
- [Batch 对象](https://runapi.ai/docs/api/protocol/batches/object.md)

---

## More from RunAPI

- [Home](https://runapi.ai/.md)
- [模型](https://runapi.ai/zh-CN/models.md)
- [AI 视频 API 对比](https://runapi.ai/zh-CN/ai-video-api-comparison.md)
- [OpenClaw 集成](https://runapi.ai/zh-CN/openclaw.md)
- [OpenClaw 最佳 API](https://runapi.ai/zh-CN/best-api-for-openclaw.md)
- [OpenClaw 图片生成](https://runapi.ai/zh-CN/openclaw-image-generation.md)
- [Hermes 智能体集成](https://runapi.ai/zh-CN/hermes-agent.md)
- [定价](https://runapi.ai/zh-CN/pricing.md)
- [Claude API 定价](https://runapi.ai/zh-CN/claude-api-pricing.md)
- [ChatGPT API 定价](https://runapi.ai/zh-CN/chatgpt-api-pricing.md)
- [OpenAI API 定价](https://runapi.ai/zh-CN/openai-api-pricing.md)
- [Gemini API 定价](https://runapi.ai/zh-CN/gemini-api-pricing.md)
- [Claude Code 定价](https://runapi.ai/zh-CN/claude-code-pricing.md)
- [Claude Code API](https://runapi.ai/zh-CN/claude-code-api.md)
- [Claude Code 对比 Cursor](https://runapi.ai/zh-CN/claude-code-vs-cursor.md)
- [Claude Max 对比 API](https://runapi.ai/zh-CN/claude-max-vs-api.md)
- [Requesty 替代方案](https://runapi.ai/zh-CN/requesty-alternative.md)
- [文档](https://runapi.ai/zh-CN/docs/guides)
- [SDK](https://runapi.ai/zh-CN/sdk.md)
- [Skills](https://runapi.ai/zh-CN/skills.md)
- [MCP Server](https://runapi.ai/zh-CN/mcp.md)
- [CLI](https://runapi.ai/zh-CN/cli.md)
- [反馈](https://runapi.ai/)
- [联系](mailto:support@runapi.ai)
- [服务条款](https://runapi.ai/zh-CN/terms.md)
- [隐私政策](https://runapi.ai/zh-CN/privacy.md)
- [Site index for agents](https://runapi.ai/llms.txt)

Contact: contact@runapi.ai

## Structured data

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-CN/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-CNicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "TechArticle",
    "headline": "取消 Batch",
    "description": "请求执行方取消尚未终态的 Batch。",
    "url": "https://runapi.ai/zh-CN/docs/api/protocol/batches/cancel",
    "mainEntityOfPage": "https://runapi.ai/zh-CN/docs/api/protocol/batches/cancel"
  }
]
```
