name: apimart-image
description: Generate images via APIMart's unified API gateway (Nano Banana Pro, GPT-Image-2, Seedream, Imagen, Qwen Image, Grok Imagine, etc.) with built-in cost estimation before each call and persistent usage logging. Use this skill whenever the user asks to generate, create, draw, render, or visualize an image; whenever they want a poster, banner, icon, illustration, thumbnail, or any visual asset; whenever they reference an APIMart image model by name (Nano Banana, Seedream, Imagen, GPT-Image, Z-Image, Wan-Image, etc.); whenever they ask "how much would it cost to generate N images of X"; and whenever they ask about image-generation spending or budget on APIMart. Use this skill even when the user does not explicitly say "APIMart" — if APIMART_API_KEY is configured, this is the canonical way to generate images. Do NOT write ad-hoc curl/python to call APIMart for images; route through this skill so cost estimation and usage logging happen consistently.
APIMart Image Generation Skill
Generate images through APIMart's OpenAI-compatible image endpoint, with automatic cost estimation, async task polling, image download, and per-call usage logging.
When to use this skill
Use this skill when the user asks to:
- Generate or create any image, poster, banner, illustration, icon, thumbnail, mockup, concept art, or visual asset
- Use a specific APIMart image model by name: Nano Banana, Nano Banana Pro, Nano Banana 2, GPT-Image-1/1.5/2, Imagen-4, Seedream-4/4.5/5-Lite, Qwen Image 2.0, Z-Image-Turbo, Grok Imagine, Wan 2.7 Image
- Estimate cost of generating N images with model X (no API call needed — the pricing table answers this)
- Check spending on APIMart image generation, daily / weekly / monthly
- Check the APIMart account balance
Do NOT use this skill for:
- Editing local image files without API generation (use other image tools)
- Video generation (APIMart has video models but this skill covers images only)
- Reading or analyzing images that already exist
Files in this skill
scripts/generate.py — Main script: estimates cost, submits task, polls until done, downloads to disk, logs usage
scripts/check_balance.py — Queries the user's APIMart account balance
scripts/show_history.py — Reads the local usage log and reports spend by day/week/month, broken down by model
references/pricing.json — Editable model→price table. Some prices verified, some estimated (see verified flag per model)
references/models.md — Quick guide for picking the right model for a given task
Configuration
The scripts read these environment variables:
APIMART_API_KEY (required) — Bearer token from the APIMart dashboard
APIMART_BASE_URL (optional, defaults to https://api.apimart.ai)
APIMART_USAGE_LOG (optional, defaults to ~/.apimart-image/usage.jsonl)
If APIMART_API_KEY is not set, the script exits with code 2 and a clear error. Tell the user to export the key.
Workflow
When asked to generate an image:
Prompt strategy (interactive). Use AskUserQuestion to ask the user how to handle their prompt:
Question: "How should I handle your prompt?"
- Optimize the prompt — I'll rewrite and enhance your description into a professional image generation prompt, preserving your intent while adding detail and artistic direction (Recommended)
- Use as-is — Translate your exact words to English literally, no additions or modifications
- Let me write my own prompt — Skip optimization, I'll provide the full English prompt myself
This MUST be the first interaction, before any other decisions.
Pick the model. Honor any explicit choice from the user. Otherwise default to nano-banana-pro (best general quality / price ratio). If unsure between two strong candidates, briefly mention the tradeoff and pick — don't ask if a sensible default exists.
Pick the size (aspect ratio). APIMart accepts ONLY ratio notation: 1:1, 16:9, 9:16, 4:3, 3:4, 21:9, 4:1, 8:1, auto. Pixel sizes like 1024x1024 are rejected with build_request_failed: invalid size. Translate user requests:
- "square" / "Instagram post" →
1:1
- "landscape" / "YouTube thumbnail" / "wallpaper" →
16:9
- "portrait" / "phone wallpaper" / "Instagram story" →
9:16
- "banner" →
21:9 or 4:1 depending on context
Pick the resolution (some models only). Nano Banana Pro and Nano Banana 2 support --resolution 1K|2K|4K. Default 1K. Only use 4K if the user explicitly asks for high resolution — it costs more.
Prompt review (interactive). Before submitting any API call, compose the final English prompt based on the user's chosen strategy from step 1. Then use AskUserQuestion to present:
Question: "Please review the prompt before submission:"
- Use the
preview field to display the prompt in a code block with both English (as submitted) and Chinese translation side by side
- Options:
- Submit as-is — Send this prompt to the API now
- I want to revise — I'll adjust the prompt based on your feedback
Do NOT proceed to step 6 until the user confirms. Only skip this step if the user explicitly says to go ahead without review.
Estimate cost. The script prints the estimate before any API call. The pricing table in references/pricing.json defines the rate per model + resolution.
Confirm if expensive. The script auto-confirms when single-call cost is below confirmation_threshold_usd (default $0.10). Above that, or for n > 4, it prompts. Pass --yes to skip prompts in non-interactive contexts.
Run the script. Pass --prompt, --model, --size, optionally --resolution, --n, --output-dir. Example:
python scripts/generate.py \
--prompt "A misty forest at dawn, watercolor" \
--model nano-banana-pro \
--size 16:9
- Report the result. The script prints the saved file paths, model, time, and actual cost. Pass that summary back to the user. If
--json was used, parse the JSON and surface the relevant fields.
Cost-only questions (no API call)
If the user asks "how much would N images of X cost on Y model", do not generate. Instead use --dry-run:
python scripts/generate.py --prompt "_" --model nano-banana-pro --n 100 --dry-run
Or just look up the price in references/pricing.json and compute mentally for simple cases. Always note whether the price is verified or an estimate.
History / spending questions
For "what did I spend this month", run:
python scripts/show_history.py --period month
Periods: day, week, month, all. The cost in the report is the estimated cost from pricing.json at the time of generation — for the authoritative number, use check_balance.py to compare against the dashboard.
Important constraints
- Async by default. All image endpoints return
task_id immediately; the script polls /v1/tasks/{task_id} every 2 seconds up to 5 minutes. Typical wait: 5–60s depending on model and resolution.
- URL expiry. APIMart result URLs expire ~24h after generation. The script downloads to local disk so the user always has the file.
- Content moderation. APIMart pre-screens prompts; rejected prompts are not billed but produce a clear error. If a generation fails moderation, suggest revising rather than retrying with the same wording.
- Pricing freshness. APIMart adjusts prices periodically. Models with
"verified": false in pricing.json are reasonable estimates that should be checked at https://apimart.ai/model before high-volume use. A user can edit pricing.json at any time.
- Don't bypass the script. Even if the agent could write its own curl/requests call, route through
generate.py so cost logging, polling, retry, and confirmation behave consistently.
Examples
Example 1 — simple generation
User: "Generate a watercolor painting of a fox in a snowy forest."
python scripts/generate.py --prompt "A fox in a snowy forest, watercolor painting" --model nano-banana-pro --size 1:1
Default model, 1:1, ~$0.04. No confirmation prompt.
Example 2 — explicit model and ratio
User: "Use Seedream 4.5 to make a 16:9 banner of a sunrise over Mount Fuji."
python scripts/generate.py --prompt "Sunrise over Mount Fuji, photographic, golden hour" --model seedream-4-5 --size 16:9
Example 3 — cost question only, no generation
User: "How much would it cost to generate 50 social-media thumbnails using Nano Banana?"
python scripts/generate.py --prompt "_" --model nano-banana --n 50 --dry-run
Report: ~$0.625 USD (50 × $0.0125). This price is verified.
Example 4 — high-quality, batch with confirmation
User: "Make me 6 variants of a sci-fi cityscape at 4K."
python scripts/generate.py --prompt "Sci-fi neon cityscape, cinematic" --model nano-banana-pro --resolution 4K --n 6 --size 16:9
Estimated $0.30 — above default $0.10 threshold, script will prompt for confirmation.
Example 5 — spending review
User: "What did I spend on AI images this month?"
python scripts/show_history.py --period month
Then report total + per-model breakdown.
1---2name: apimart-image3description: Generate images via APIMart's unified API gateway (Nano Banana Pro, GPT-Image-2, Seedream, Imagen, Qwen Image, Grok Imagine, etc.) with built-in cost estimation4---5---6name: apimart-image7description: Generate images via APIMart's unified API gateway (Nano Banana Pro, GPT-Image-2, Seedream, Imagen, Qwen Image, Grok Imagine, etc.) with built-in cost estimation before each call and persistent usage logging. Use this skill whenever the user asks to generate, create, draw, render, or visualize an image; whenever they want a poster, banner, icon, illustration, thumbnail, or any visual asset; whenever they reference an APIMart image model by name (Nano Banana, Seedream, Imagen, GPT-Image, Z-Image, Wan-Image, etc.); whenever they ask "how much would it cost to generate N images of X"; and whenever they ask about image-generation spending or budget on APIMart. Use this skill even when the user does not explicitly say "APIMart" — if APIMART_API_KEY is configured, this is the canonical way to generate images. Do NOT write ad-hoc curl/python to call APIMart for images; route through this skill so cost estimation and usage logging happen consistently.8---910# APIMart Image Generation Skill1112Generate images through APIMart's OpenAI-compatible image endpoint, with automatic cost estimation, async task polling, image download, and per-call usage logging.1314## When to use this skill1516Use this skill when the user asks to:1718- **Generate or create** any image, poster, banner, illustration, icon, thumbnail, mockup, concept art, or visual asset19- Use a specific APIMart image model by name: Nano Banana, Nano Banana Pro, Nano Banana 2, GPT-Image-1/1.5/2, Imagen-4, Seedream-4/4.5/5-Lite, Qwen Image 2.0, Z-Image-Turbo, Grok Imagine, Wan 2.7 Image20- **Estimate cost** of generating N images with model X (no API call needed — the pricing table answers this)21- **Check spending** on APIMart image generation, daily / weekly / monthly22- **Check the APIMart account balance**2324Do NOT use this skill for:2526- Editing local image files without API generation (use other image tools)27- Video generation (APIMart has video models but this skill covers images only)28- Reading or analyzing images that already exist2930## Files in this skill3132- `scripts/generate.py` — Main script: estimates cost, submits task, polls until done, downloads to disk, logs usage33- `scripts/check_balance.py` — Queries the user's APIMart account balance34- `scripts/show_history.py` — Reads the local usage log and reports spend by day/week/month, broken down by model35- `references/pricing.json` — Editable model→price table. Some prices verified, some estimated (see `verified` flag per model)36- `references/models.md` — Quick guide for picking the right model for a given task3738## Configuration3940The scripts read these environment variables:4142- `APIMART_API_KEY` (required) — Bearer token from the APIMart dashboard43- `APIMART_BASE_URL` (optional, defaults to `https://api.apimart.ai`)44- `APIMART_USAGE_LOG` (optional, defaults to `~/.apimart-image/usage.jsonl`)4546If `APIMART_API_KEY` is not set, the script exits with code 2 and a clear error. Tell the user to export the key.4748## Workflow4950When asked to generate an image:51521. **Prompt strategy (interactive).** Use `AskUserQuestion` to ask the user how to handle their prompt:5354 **Question:** "How should I handle your prompt?"55 - **Optimize the prompt** — I'll rewrite and enhance your description into a professional image generation prompt, preserving your intent while adding detail and artistic direction (Recommended)56 - **Use as-is** — Translate your exact words to English literally, no additions or modifications57 - **Let me write my own prompt** — Skip optimization, I'll provide the full English prompt myself5859 This MUST be the first interaction, before any other decisions.60612. **Pick the model.** Honor any explicit choice from the user. Otherwise default to `nano-banana-pro` (best general quality / price ratio). If unsure between two strong candidates, briefly mention the tradeoff and pick — don't ask if a sensible default exists.62633. **Pick the size (aspect ratio).** APIMart accepts ONLY ratio notation: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `21:9`, `4:1`, `8:1`, `auto`. **Pixel sizes like `1024x1024` are rejected** with `build_request_failed: invalid size`. Translate user requests:64 - "square" / "Instagram post" → `1:1`65 - "landscape" / "YouTube thumbnail" / "wallpaper" → `16:9`66 - "portrait" / "phone wallpaper" / "Instagram story" → `9:16`67 - "banner" → `21:9` or `4:1` depending on context68694. **Pick the resolution (some models only).** Nano Banana Pro and Nano Banana 2 support `--resolution 1K|2K|4K`. Default 1K. Only use 4K if the user explicitly asks for high resolution — it costs more.70715. **Prompt review (interactive).** Before submitting any API call, compose the final English prompt based on the user's chosen strategy from step 1. Then use `AskUserQuestion` to present:7273 **Question:** "Please review the prompt before submission:"74 - Use the `preview` field to display the prompt in a code block with both English (as submitted) and Chinese translation side by side75 - Options:76 - **Submit as-is** — Send this prompt to the API now77 - **I want to revise** — I'll adjust the prompt based on your feedback7879 Do NOT proceed to step 6 until the user confirms. Only skip this step if the user explicitly says to go ahead without review.80816. **Estimate cost.** The script prints the estimate before any API call. The pricing table in `references/pricing.json` defines the rate per model + resolution.82837. **Confirm if expensive.** The script auto-confirms when single-call cost is below `confirmation_threshold_usd` (default $0.10). Above that, or for `n > 4`, it prompts. Pass `--yes` to skip prompts in non-interactive contexts.84858. **Run the script.** Pass `--prompt`, `--model`, `--size`, optionally `--resolution`, `--n`, `--output-dir`. Example:8687```bash88python scripts/generate.py \89 --prompt "A misty forest at dawn, watercolor" \90 --model nano-banana-pro \91 --size 16:992```93949. **Report the result.** The script prints the saved file paths, model, time, and actual cost. Pass that summary back to the user. If `--json` was used, parse the JSON and surface the relevant fields.9596## Cost-only questions (no API call)9798If the user asks "how much would N images of X cost on Y model", **do not** generate. Instead use `--dry-run`:99100```bash101python scripts/generate.py --prompt "_" --model nano-banana-pro --n 100 --dry-run102```103104Or just look up the price in `references/pricing.json` and compute mentally for simple cases. Always note whether the price is `verified` or an estimate.105106## History / spending questions107108For "what did I spend this month", run:109110```bash111python scripts/show_history.py --period month112```113114Periods: `day`, `week`, `month`, `all`. The cost in the report is the **estimated** cost from `pricing.json` at the time of generation — for the authoritative number, use `check_balance.py` to compare against the dashboard.115116## Important constraints117118- **Async by default.** All image endpoints return `task_id` immediately; the script polls `/v1/tasks/{task_id}` every 2 seconds up to 5 minutes. Typical wait: 5–60s depending on model and resolution.119- **URL expiry.** APIMart result URLs expire ~24h after generation. The script downloads to local disk so the user always has the file.120- **Content moderation.** APIMart pre-screens prompts; rejected prompts are not billed but produce a clear error. If a generation fails moderation, suggest revising rather than retrying with the same wording.121- **Pricing freshness.** APIMart adjusts prices periodically. Models with `"verified": false` in `pricing.json` are reasonable estimates that should be checked at <https://apimart.ai/model> before high-volume use. A user can edit `pricing.json` at any time.122- **Don't bypass the script.** Even if the agent could write its own curl/requests call, route through `generate.py` so cost logging, polling, retry, and confirmation behave consistently.123124## Examples125126**Example 1 — simple generation**127> User: "Generate a watercolor painting of a fox in a snowy forest."128129```bash130python scripts/generate.py --prompt "A fox in a snowy forest, watercolor painting" --model nano-banana-pro --size 1:1131```132133Default model, 1:1, ~$0.04. No confirmation prompt.134135**Example 2 — explicit model and ratio**136> User: "Use Seedream 4.5 to make a 16:9 banner of a sunrise over Mount Fuji."137138```bash139python scripts/generate.py --prompt "Sunrise over Mount Fuji, photographic, golden hour" --model seedream-4-5 --size 16:9140```141142**Example 3 — cost question only, no generation**143> User: "How much would it cost to generate 50 social-media thumbnails using Nano Banana?"144145```bash146python scripts/generate.py --prompt "_" --model nano-banana --n 50 --dry-run147```148149Report: ~$0.625 USD (50 × $0.0125). This price is verified.150151**Example 4 — high-quality, batch with confirmation**152> User: "Make me 6 variants of a sci-fi cityscape at 4K."153154```bash155python scripts/generate.py --prompt "Sci-fi neon cityscape, cinematic" --model nano-banana-pro --resolution 4K --n 6 --size 16:9156```157158Estimated $0.30 — above default $0.10 threshold, script will prompt for confirmation.159160**Example 5 — spending review**161> User: "What did I spend on AI images this month?"162163```bash164python scripts/show_history.py --period month165```166167Then report total + per-model breakdown.