SparkCode Image
Use scripts/generate_image.py for deterministic API calls. Keep credentials in this skill's
.cache/config.json; never put a key in source code, prompts, logs, or delivered artifacts.
Initialize
Run python scripts/configure.py status before the first API call.
If configuration is missing, read references/onboarding.md, guide the
user through account setup, and ask them to provide the newly created token. Then run
python scripts/configure.py configure in an interactive terminal and enter the token through the
hidden prompt. Do not echo it. Initialization is complete only when status reports configured.
The cache deliberately lives inside this skill for portability. Before sharing the skill, run
python scripts/configure.py clear or delete .cache/.
Workflow
1. Classify the task
Choose exactly one primary type:
- Generate from scratch
- Modify an existing image
- Portrait retouching
- Product scene
- Infographic or flowchart
- Single PPT slide
- Complete presentation image set
- Poster or social-media visual
For a complete presentation, create a slide list and render one coherent 16:9 image per slide.
If the user needs an editable .pptx, use a presentation capability afterward to assemble the
generated slide images; this skill only produces image assets.
2. Extract inputs
Identify:
- use case and target audience
- core message
- exact text, numbers, labels, logos, and data that must be preserved
- reference/input images
- aspect ratio and resolution
- brand or visual style
- regions or elements that must not change
Infer safe defaults when the request is clear. Ask one concise question only when a required input
image is missing, mandatory copy/data is ambiguous, or a choice would materially change the result.
3. Plan before generating
Write a compact internal plan covering:
- information compression
- content hierarchy
- composition
- layout system
- primary visual
- intentional whitespace
For text-heavy Chinese visuals, shorten copy without changing meaning and favor fewer, larger text
blocks. Use references/prompt-workflow.md for task-specific planning.
4. Select output settings
Resolution is a real, honored parameter — always pass --resolution explicitly rather than relying
on the default, and pass whatever the user asked for. Use 2K by default for final work, 1K for
inexpensive drafts, 512 for throwaway checks, 4K for high-detail or text-heavy final work, and
auto only when the user explicitly wants the model to decide.
Use 16:9 for PPT slides and horizontal infographics, 9:16 for stories, 4:5 for social feeds,
1:1 for square posts/products, and preserve an input image's ratio for edits unless the user asks
to reframe. Supported ratios and the measured output size of each setting are listed in
references/api.md.
If the user asks for a resolution or ratio, never substitute another value and never leave it at a
default. Both settings only take effect when nested under extra_body.google.image_config, which the
script does; a top-level image_config is silently ignored by the gateway.
Use gemini-3.1-flash-image by default. Retry once with
gemini-3.1-flash-image-preview only when the default model has no available channel or the user
explicitly requests Preview. Do not silently downgrade resolution or change ratio.
5. Build the final prompt
Include the task, intended use, audience, exact required content, composition, hierarchy, style,
ratio, resolution, and preservation constraints. For edits, explicitly identify what may change and
state that everything else must remain unchanged.
Always append these constraints:
- Use correct Simplified Chinese; no misspellings, fake glyphs, or garbled text.
- Preserve all user-provided data exactly.
- Do not invent business conclusions or unsupported claims.
- Keep unspecified areas unchanged during edits.
- Preserve identity and recognizable facial features in portrait work.
- Avoid crowded pages and meaningless English decoration.
- Do not add watermarks, signatures, or brand marks that were not supplied.
6. Generate or edit
Run from the user's desired output directory:
python <skill-dir>\scripts\generate_image.py --prompt-file <prompt.txt> --task-type infographic --aspect-ratio 16:9 --resolution 2K --output <image.png>
For an edit, add one or more --input <path> arguments. Never use an edit workflow without the
actual source image. Do not write temporary prompts or outputs inside the skill directory.
The command prints JSON containing the real format, width, and height of every saved file. The
API often returns JPEG, so the saved extension may differ from the one you passed — report the
path from that JSON, not the path you requested. Add --print-payload when a setting appears to be
ignored; it dumps the outgoing request body (minus image data) to stderr.
7. Verify
Open every output image and check:
- file is a valid, non-empty image
- the reported
width/heightmatch the requested ratio and resolution tier
(512≈0.5K,1K≈1024,2K≈2048,4K≈4096 on the long side; a 1408x768 result for a non-16:9
request means the settings were dropped, not honored) - required text and data are present and accurate
- layout is legible at normal viewing size
- preserved content remains intact
- no watermark, garbled text, or unintended additions appear
Regenerate with a corrected prompt when these checks fail. Do not claim exact text correctness
without visual inspection.
Commands
python scripts/configure.py status
python scripts/configure.py configure
python scripts/configure.py clear
python scripts/generate_image.py --help