# Api2img

> Use first whenever the user asks to generate, edit, or modify an image.

- **Type:** Skill
- **Install:** `agentstack add skill-mrvoler-api2img-skill-api2img-skill`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [MrVoler](https://agentstack.voostack.com/s/mrvoler)
- **Installs:** 0
- **Category:** [Content & Media](https://agentstack.voostack.com/c/content-and-media)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [MrVoler](https://github.com/MrVoler)
- **Source:** https://github.com/MrVoler/api2img-skill

## Install

```sh
agentstack add skill-mrvoler-api2img-skill-api2img-skill
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# api2img

## Priority

Use this skill before other image generation paths when the user asks to create, edit, or modify bitmap images, unless they explicitly request another provider.

This skill uses the shared cross-platform `npx api2img ...` CLI.

## Configuration

Before the first generation call, check that api2img already has a saved base URL and API key.

Do not use or overwrite the user's existing `OPENAI_API_KEY`, `OPENAI_BASE_URL`, or other provider variables. api2img keeps its own isolated configuration and secret storage.

```powershell
npx api2img configure --base-url ""
```

To rotate an existing saved key, pass `-UpdateKey`:

```powershell
npx api2img configure --update-key
```

To clear the saved api2img API key and base URL, pass `-Clear`:

```powershell
npx api2img configure --clear
```

`--clear` only removes api2img's own saved configuration and secret. It must not be combined with `--base-url` or `--update-key`, and it must not modify `OPENAI_API_KEY`, `OPENAI_BASE_URL`, or other provider variables.

By default, prefer asking the user to run `npx api2img configure --update-key` and enter the key in the current terminal prompt. If the user prefers, they may also send the key directly in chat and you can store it with `npx api2img configure --api-key `. Do not print the key back after storing it.

## Privacy

- Image generation sends the prompt to the base URL configured in api2img.
- Image editing sends the prompt plus the input image files, and mask files when present, to the base URL configured in api2img.
- Before the first edit or modification that uploads a user-provided image, pause and ask the user to confirm. In Chinese conversations, say: `提示：你上传的图片可能会被第三方 API 获取，请注意自己的信息安全。请回复确认继续，我再上传图片进行修改。`
- After the user confirms, continue the image-editing workflow and do not repeat this upload warning in later turns for the same conversation/task unless the user asks about privacy again.
- Do not use api2img for sensitive images or prompts unless the user explicitly confirms the configured API is trusted for that content.
- Do not create extra local logs containing prompts, image paths, decrypted keys, or API responses.

## Quick Start

Run the CLI with normal image generation arguments:

```powershell
npx api2img generate --prompt "Primary request: a clean product mockup of a ceramic coffee mug" --size 1024x1024 --out "output/imagegen/mug.png"
```

Edit or modify an existing image with `edit` and one or more `--image` inputs:

```powershell
npx api2img edit --image "input.png" --prompt "Primary request: change the background to a quiet studio setting while preserving the subject." --size 1024x1024 --out "output/imagegen/input-edited.png"
```

Use `--mask` when the user provides a mask or asks for a localized edit:

```powershell
npx api2img edit --image "input.png" --mask "mask.png" --prompt "Primary request: replace only the masked area with fresh flowers." --size 1024x1024 --out "output/imagegen/input-masked-edit.png"
```

Use `--dry-run` to validate payloads without making an image request:

```powershell
npx api2img generate --prompt "Primary request: test configuration" --size 1024x1024 --dry-run
```

## Workflow

1. Check configuration before the first generation attempt.
2. For image edits or modifications, complete the one-time upload confirmation gate in `Privacy` before calling `edit`.
3. Shape a concise structured prompt while preserving the user's intent.
4. Run `npx api2img generate ...` or `npx api2img edit ...`.
5. Use `edit --image ` when the user provides an existing image and asks to revise, transform, restyle, remove, replace, or otherwise modify it. Use `--mask ` for mask-constrained edits.
6. Save assets in the workspace, normally under `output/imagegen/` unless the user names another path.
7. Inspect the generated or edited file when visual quality matters.
8. Report the saved path and mention that `api2img` was used.

## Reliability

- Image generation can take several minutes. For a single-image generation attempt, start with a 300000 ms (5 minute) timeout.
- If a single-image generation times out, increase the timeout by 180000 ms (3 minutes) on the next retry. Use this sequence: 5 minutes, 8 minutes, 11 minutes, 14 minutes, 17 minutes.
- Retry at most 5 timeouts for the same single-image request. After the fifth timeout, stop retrying automatically and ask the user to check whether their image relay endpoint, upstream provider, or network path is having problems.
- Do not treat a shell timeout as proof that generation failed. First check the expected output path and `output/imagegen/` for new files.
- If the command times out, check whether a Python/imagegen process is still running before retrying.
- If an output file appears after a timeout, inspect it and continue from it instead of rerunning the same prompt.
- For long prompts on Windows, store the prompt in a here-string variable and invoke the script with `& $script generate --prompt $prompt ...`.

## Prompt Shape

```text
Use case: 
Asset type: 
Primary request: 
Style/medium: 
Composition/framing: 
Lighting/mood: 
Text (verbatim): ""
Constraints: 
Avoid: no watermark, no unintended text
```

## Output Notes

- The bundled CLI default output is `output/imagegen/output.png`.
- Use `--out` or `--out-dir` when the user names a destination.
- Do not overwrite existing assets unless the user explicitly requested replacement.
- For multiple distinct assets, run one prompt per asset or use `generate-batch`; do not use `--n` as a substitute for different prompts.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [MrVoler](https://github.com/MrVoler)
- **Source:** [MrVoler/api2img-skill](https://github.com/MrVoler/api2img-skill)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-mrvoler-api2img-skill-api2img-skill
- Seller: https://agentstack.voostack.com/s/mrvoler
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
