Generate images based on prompts and reference images, support multiple AI models, create tasks asynchronously and poll for results.
Core Features
- Multiple model options: 7 models available, each with different strengths and resolution support.
- Image-to-image: pass in a reference image + prompt to generate a new image.
- Batch output: generate up to 10 images in a single run.
- Asynchronous mode: creating a task immediately returns a taskId, and the script automatically polls until completion (10-minute timeout).
Model Description
| Model (provider) | Description | Features |
|---|---|---|
| BANANA | LFBanana (basic version) | Only supports 1K resolution |
| BANANA_2 | LFBanana2 | Supports higher resolution |
| BANANA_PRO | LFBanana Pro (default) | Best overall results |
| GPT_2_IMAGE | Img2 | Supports the quality parameter to control quality |
| AIDRAW_EDIT | Linkfox-Image-1 | Suitable for editing scenarios |
| WAN2_7 | Wan 2.7 | Wanxiang model |
| SEEDREAM5 | Seedream 5.0 | Only supports 2K |
Parameter Overview
- Required fields:
prompt、imageUrls、outputNum(default1)、resolution(default1K)、quality(defaulthigh, only GPT_2_IMAGE)
For the complete parameter table, response field structure, and error codes, see references/api.md。
How to Call
- Create task:
POST /aigc/imageGenAsync→ returns{taskId} - Poll result:
POST /aigc/taskQuery→ pass in{taskId}→ returns status and result - Python script:
python scripts/aigc_imagegen.py '<JSON 参数>'(the script automatically completes creation + polling internally)
Asynchronous flow:
- The script calls
/aigc/imageGenAsyncto create a task and obtaintaskId - Poll
/aigc/taskQuery, initial interval 10 seconds, decreasing by 1 second each time to a minimum of 5 seconds, maximum wait 10 minutes - After success, automatically download the image to the session
media/directory
File storage path convention(follows the CLAUDE.md specification):
All files are stored under <cwd>/linkfox/<YYYY-MM-DD>/<session>/ , divided into directories by type:
| Content type | Directory | Path format | Description |
|---|---|---|---|
| Generated image | media/ |
<session>/media/linkfox-aigc-imagegen-<ts_ms>.<ext> |
such as media/linkfox-aigc-imagegen-1718000000000.png |
| Raw API response | data/ |
<session>/data/linkfox-aigc-imagegen-<ts>.json |
contains the complete taskId, status, temporary URL, etc. |
Output strategy (default script behavior):
-
On successful image generation(regardless of how many):
- stdout outputs
Saved full response: <路径数组>format lines, for example:- 1 image:
Saved full response: ["/path/to/media/a.png"] - Multiple images:
Saved full response: ["/path/to/media/a.png", "/path/to/media/b.png"]
- 1 image:
- The raw API response (including temporary URLs, etc.) is silently written to disk at
data/。 - The frontend UI can parseall
Saved full response:lines and render the subsequent JSON arrays. - Each script call usually outputs one line; when called multiple times, there will be multiple lines.
- stdout outputs
-
When there is no image output(failure/no result):
- stdout outputs the raw response path:
Saved full response: /path/to/data/xxx.json
- stdout outputs the raw response path:
Data reading recommendations:Do not Read the content of the image file saved by Read (to avoid base64 entering the context). Simply provide the local path after Saved full response: to the user.
Resolve authentication and compute quota issues
When the following exceptions occur, use references/onboarding.md to guide problem resolution:
Exceptions
- API Key not configured: The environment variable is not configured
LINKFOX_AGENT_API_KEY, andLINKFOXAGENT_API_KEY。 - Response 401 or 402 status code
- Response indicates insufficient compute quota or balance: The message contains "insufficient compute quota/insufficient billing/insufficient balance/quota exceeded/insufficient balance/package expired/recharge required/please recharge", or content with similar meaning.
Usage guidelines
- Model selection: For general scenarios use
BANANA_PRO(default); for high-quality image quality control useGPT_2_IMAGE; to edit existing images useAIDRAW_EDIT。 - Prompts: The more specific the description, the better the result. English prompts are recommended for better results.
- Reference image: At least one reference image URL must be provided.
- Resolution: Supports 1K/2K/4K, default 1K.
Examples
1. Generate a product scene image with the default model
{"imageUrls": ["https://example.com/product.jpg"], "prompt": "product photography on white background, studio lighting", "provider": "BANANA_PRO", "outputNum": 1, "resolution": "1K", "aspectRatio": "1:1", "quality": "high"}
2. Generate high-quality images with GPT_2_IMAGE
{"imageUrls": ["https://example.com/ref.jpg"], "prompt": "modern minimalist product showcase", "provider": "GPT_2_IMAGE", "outputNum": 1, "resolution": "1K", "aspectRatio": "16:9", "quality": "high"}
3. Generate multiple images in batch
{"imageUrls": ["https://example.com/ref.jpg"], "prompt": "creative product ad design", "provider": "BANANA_PRO", "outputNum": 4, "resolution": "2K", "aspectRatio": "1:1", "quality": "high"}
Limitations
- At least one reference image URL must be provided.
- Generate up to 10 images per request.
- Generation time varies by model and resolution, typically 10-120 seconds. The script automatically polls, with a 10-minute timeout.
- Do not retry on failure (only 1 attempt).
Not applicable
Not applicable:
- Text-only generation →
linkfox-aigc-textgen - Video generation →
linkfox-aigc-videogen
Feedback
See references/api.md。
Execute instructions
Important: After receiving the ARGUMENTS: field at the end of this document, you must immediately call python scripts/aigc_imagegen.py '<JSON>' to execute,do not wait for user confirmation or additional input。