batch-api
What it does
It prepares a plan for transforming many files in one step, such as translating or rewriting them, and submits it to a batch service at half the realtime price. Results arrive later as new files. It is for people who can wait hours for lower-cost bulk work.
When to use it
- βWhen you need the same single-turn change applied to many files and can wait hours for the result.
- βWhen you want to translate, rewrite or extract content across a large set of files at lower cost.
- βWhen you explicitly want the batch pricing and not a realtime run.
Skill link
https://github.com/QwenLM/qwen-code/blob/main/packages/core/src/skills/bundled/batch-api/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI want to translate all of my product description files into Spanish using the cheaper batch option, and I can wait for the results.β
5 new skills a week. 1 minute to read.
How it works
The agent prepares a plan file that describes the files and the transform, then a command submits the job. The agent does not write the requests itself, and results come back as new files.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
/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
It proves the credentials, endpoint and Batch route work and shows the model,
thinking mode and output limit a run would freeze from the user's current
settings β without a billed request. settings.batch.model can select a
separate modelProviders entry; its endpoint, envKey and generationConfig are
used without changing the conversation model. Do not edit authentication or
settings to work around a failed check. If it fails (for example Qwen OAuth, which has no Batch route),
relay its message and stop: do not read files or draft a plan the executor
cannot submit. Pass its note: lines on to the user.
1. Decide suitability honestly β this is your main job
Suitable: many independent, single-turn transforms whose input materials are fully available right now. Examples: translate a set of documents under a fixed style guide, rewrite files to a new format, summarize or extract structured data from each file of a set.
Unsuitable:
- Work that needs iterative feedback β debugging, run-test-fix loops, exploratory refactors. The next step there depends on results that do not exist yet.
- Chained tasks where one item's output is another item's input.
- A handful of items, or a task the user needs answered soon. Batch's wait buys nothing there.
If the task is unsuitable, say so in one short paragraph and stop.
2. Prepare lightly
The whole point is saving money, so do not burn the savings in preparation:
- Discover the target files with glob.
- Read only a small sample (2β3 files) to understand structure and edge cases. Do NOT deeply read every file β the executor reads and embeds the full contents mechanically at submission time.
- Draft the shared rules once: terminology, style, format constraints, and the exact output contract. The model that runs the batch sees only your plan β spell out everything it needs, including "return ONLY the complete transformed document, no commentary".
3. Write the plan file
Write one JSON file to .qwen/batch/plans/<slug>.json (<slug> = short
kebab-case task name) with the write_file tool:
{
"version": 1,
"name": "<slug>",
"kind": "document-transform",
"shared": {
"system": "optional role/system prompt",
"instructions": "the shared transform rules, terminology, output contract"
},
"items": [
{
"id": "intro",
"source": "docs/zh/intro.md",
"target": "docs/en/intro.md"
}
]
}
Rules:
idmust match[A-Za-z0-9][A-Za-z0-9_-]{0,59}(1β60 characters) and be unique per item; it becomes part of the provider-sidecustom_id.- Paths are relative to the curr
FAQ
How much cheaper is it?
The batch service bills these requests at half the realtime list price, with no context-cache benefit.
How long does a job take?
Jobs can take tens of minutes to hours, with a completion window of 24 hours or more.
What happens if the batch command fails?
The agent reports what happened and stops. It does not quietly do the work at full realtime price instead.
Details
Original description by the author
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.
repo: QwenLM/qwen-code
Popularity
- GitHub stars
- 29k
- Ranking position
- #9776
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
codegraph
29kHelps your agent analyze an indexed codebase through its call graph, dependencies, dead code, hotspots and semantic search.
qwen-code-claw
29kHelps your agent hand coding tasks to Qwen Code, such as understanding a codebase, fixing bugs, refactoring code or generating a new project.
structured-debugging
29kTeaches your agent a step-by-step way to debug hard bugs: form a hypothesis, add targeted checks, test it and find the real cause before fixing.
tmux-real-user-testing
29kHelps your agent test a terminal app like a real user inside tmux, saving a step-by-step readable log with a screen snapshot of each action.
Similar skills
knowledge-automation
394kHelps your agent set up a recurring job that brings new content into your Knowledge vault on a schedule, then checks that the job runs.
knowledge-source-ingest
394kHelps your agent keep a Knowledge vault current with new items from chat channels, feeds, or mailboxes, without re-adding what it already has.
benchmark
280kHelps your agent measure code speed and performance. It's useful for ensuring things are fast and finding slowness issues.