English | ็ฎไฝไธญๆ
A CLI tool for batch testing Image/Video generation APIs. It supports flexible input parameter combinations, asynchronous concurrent requests, and resume functionality.
- YAML Configuration Driven: A single YAML file describes the entire test plan.
- Flexible Parameter Combinations: Supports four parameter modes: fixed values, random selection, file system scanning (glob), and reading from file content.
- Three Combination Strategies: Cartesian product (
product), pairwise alignment (zip), and random selection (random). - Asynchronous Concurrency: Built with
httpx+asynciofor controlled concurrency. - Resume Functionality: Automatically skips already completed tasks, allowing for easy retries after interruption.
- Result Persistence: Outputs files and logs results in JSONL format.
- Response Error Classification: If the response body contains an
errorobject, the task is recorded asfailed(notsuccess) to avoid incorrect resume skips.
# Ensure uv is installed
uv syncCopy the example configuration and modify it:
cp configs/example.yaml configs/my_task.yamlCopy .env.example to .env and fill in your actual Keys:
cp .env.example .env
# Edit .env and fill in your API Key and Base URLExample .env file (supports multiple API providers):
# DeerAPI
DEERAPI_KEY=sk-your-deerapi-key
DEERAPI_BASE_URL=https://api.deerapi.com/v1
# Volcengine (Ark)
VOLCENGINE_KEY=your-volcengine-key
VOLCENGINE_BASE_URL=https://ark.cn-beijing.volces.com/api/v3Reference them in your YAML config using ${VAR_NAME}:
api:
base_url: "${DEERAPI_BASE_URL}/images/generations"
api_key: "${DEERAPI_KEY}"Note: The
.envfile is ignored by.gitignoreand will not be committed. System environment variables take precedence over the.envfile.
uv run python main.py configs/my_task.yaml --dryuv run python main.py configs/my_task.yaml| Mode | Syntax | Description |
|---|---|---|
| Fixed Value | model: "gpt-4" |
Same value used for all tasks |
| Pick One | prompt: { pick: ["a", "b"] } |
Randomly selects one for each task |
| Glob Scan | image: { glob: "*.png", as: "base64" } |
Scans files and encodes content |
| File Content | prompt: { file: "p.txt", split: "line" } |
Reads file and splits by line |
| Value | Description |
|---|---|
base64 |
Encodes file content as base64 (default) |
path |
Absolute path string of the file |
filename |
Only the filename |
| Field | Value | Description |
|---|---|---|
image_encode |
none |
Keep original file bytes (default) |
image_encode |
smart_jpeg |
Convert static non-transparent images to JPEG when smaller |
jpeg_quality |
1-95 |
JPEG quality for smart_jpeg (default: 95) |
Example:
params:
image:
glob: "inputs/images/*"
as: "base64"
image_encode: "smart_jpeg"
jpeg_quality: 95| Strategy | Description | Example |
|---|---|---|
product |
Cartesian Product | 3 prompts ร 5 images = 15 tasks |
zip |
Pairwise alignment | prompt[0]+image[0]... |
random |
Randomly pick for pick mode, product for others |
5 images ร random prompt |
| Type | Description |
|---|---|
base64_image |
Base64 encoded image |
base64_video |
Base64 encoded video |
url |
Download resource from URL |
api-batch-tester/
โโโ main.py # CLI Entry point
โโโ .env.example # Environment variable template
โโโ configs/ # Configuration directory
โ โโโ example.yaml # Full example
โ โโโ example_random_prompt.yaml # Random prompt example
โโโ src/
โ โโโ config.py # Configuration loading and validation
โ โโโ runner.py # Batch execution engine
โ โโโ param_resolver.py # Parameter resolver
โ โโโ api_client.py # Async HTTP client
โ โโโ result_tracker.py # Result tracking (checkpoint/resume)
โ โโโ utils.py # Utility functions
โโโ external/ # External reference code (not part of the build)