# Batch API

Prepare a many-file, single-turn transform (translate, rewrite, extract) as a plan and...

- Repository: https://github.com/QwenLM/qwen-code (28858 stars)
- Category: Writing
- License: Apache-2.0
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add QwenLM/qwen-code --skill batch-api -g -a claude-code -y`
Codex: `npx skills add QwenLM/qwen-code --skill batch-api -g -a codex -y`
Cursor: `npx skills add QwenLM/qwen-code --skill batch-api -g -a cursor -y`
Gemini CLI: `npx skills add QwenLM/qwen-code --skill batch-api -g -a gemini-cli -y`

## Description

Prepare a many-file, single-turn transform (translate, rewrite, extract) as a plan and submit it to the asynchronous, half-price DashScope Batch API; results are delivered as new files hours later. Invoke explicitly with /batch-api.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# /batch-api, Agent-prepared Batch API workflow

**Hard rule for this whole skill:** if any `qwen batch …` command fails, or
the task turns out to be unsuitable, report what happened in a few lines and
stop (the one exception, a plan-field error from `run`, is in §4). Never fall back to doing the transform yourself in this session, the
user chose the half-price asynchronous path explicitly, and silently doing
the work at full realtime price is exactly what they opted out of. Offering
it as a choice ("I can do this realtime instead, at full price") is fine;
doing it without being asked is not.

The user explicitly chose **async batch mode** by typing `/batch-api`. This mode
trades latency for price: the provider bills Batch requests at 50% of the
realtime list price (with no context-cache benefit), and a job takes tens of
minutes to hours to finish (completion window 24h or more). Your job is to
turn the user's task into a small **plan file** that the deterministic
executor (`qwen batch run`) submits. You never write request JSONL by hand
and never call the Batch API yourself.

## 0. Check readiness before anything else

Run every `qwen batch …` command with the shell tool as
`"${QWEN_CODE_CLI:-qwen}" batch …`, `QWEN_CODE_CLI` names the CLI running
this session, so a plain `qwen` on PATH (possibly an older install without
these subcommands) is only the fallback. First make sure the CLI you reach
has them. Help output never calls a model:

```
"${QWEN_CODE_CLI:-qwen}" batch --help
```

If the output does not list `batch run <plan>`, the `qwen` it reached is an
older install without these subcommands, say so (the session's CLI is not on
PATH as `qwen`) and stop. Do not run any other `batch` command there: an older
CLI treats `batch check` as a prompt and answers it with a billed model call.
Then:

```
"${QWEN_CODE_CLI:-qwen}" batch check
```

The rest: https://github.com/QwenLM/qwen-code/blob/HEAD/packages/core/src/skills/bundled/batch-api/SKILL.md
