controllable-image-model-integration

/home/avalon/.hermes/skills/software-development/controllable-image-model-integration/SKILL.md · raw

Controllable Image Model Integration

Overview

Use this skill when building or auditing an interface for an image model that supports spatial grounding, marked-image editing, multi-reference composition, semantic layer separation, or iterative design edits.

The central rule is to separate three contracts:

  1. Model semantics — what the upstream model owner documents.
  2. Provider transport — what a wrapper endpoint accepts and returns.
  3. Runtime evidence — what a cost-bounded canary actually produces.

A wrapper may transport advanced behavior through an ordinary prompt plus ordered image array. The lack of a dedicated schema field is not proof that the model capability is absent. Conversely, product marketing is not proof of a stable machine contract. Reconcile both with a canary.

Trigger conditions

Load this skill for tasks involving any of:

Evidence hierarchy

Collect evidence in this order:

  1. Owner-authored model documentation and examples
  2. Exact provider endpoint schema and current pricing
  3. Provider product page, examples, share records, and demo media
  4. A minimal paid canary with an explicit maximum cost
  5. Third-party guides, clearly labeled as secondary evidence

Do not collapse evidence classes. Report, for example:

Spatial-control decision tree

Typed coordinate syntax exists upstream

A point or box drawn only for display, without corresponding model input, is UI theater.

No typed lasso/polygon syntax exists

Use visual grounding:

  1. Draw marks into a copy of the source image.
  2. Send the marked raster as an ordered model input.
  3. Describe each visible mark in natural language.
  4. Tell the model to remove all annotation strokes from the result.
  5. Keep the clean original available for retries and comparison.

Point/box tokens and raster annotations can be combined, but do not rasterize everything by default when a more exact owner-documented token exists.

Multi-reference discipline

Semantic layer experiments

Semantic decomposition is not ordinary background removal.

A good layer prompt specifies:

Do not assume a provider’s “number of images” parameter is the layer count. It may mean independent rerolls. Verify the endpoint definition and keep variant count separate from semantic layer count.

Cost-bounded canary procedure

  1. Re-check current provider pricing and input-reference surcharges.
  2. Use the lowest adequate resolution.
  3. Select a simple source with visually separable elements.
  4. Request three or four named layers before trying ten or more.
  5. Use one provider generation unless the wrapper explicitly documents a layer-count field.
  6. Require explicit approval against a conservative upper bound.
  7. Save a sanitized response-shape fixture without keys or signed sensitive data.
  8. Download and inspect every returned asset before coding a parser around assumptions.

For per-output pricing with additional-input fees, a conservative formula is:

(base_output_price + max(0, input_count - 1) * additional_input_price) * possible_output_count

Output verification

For every provider output, in original order:

  1. Download immediately to durable authenticated storage.
  2. Preserve original bytes separately from user transforms.
  3. Decode the real file; do not trust extensions or response labels.
  4. Record format, dimensions, and alpha-channel presence.
  5. Scan alpha values; an alpha channel alone does not prove transparency.
  6. Mark alpha_min < 255 as evidence that at least one pixel is not fully opaque.
  7. Verify dimensions and registration match before stacking.
  8. Label opaque results as candidates rather than validated transparent layers.

Recommended metadata:

order, filename, width, height, format, has_alpha,
alpha_min, alpha_max, alpha_mean, transparent,
provider_request_id_present, response_order_preserved

Lightweight interface pattern

Use four coupled surfaces:

Useful safeguards and affordances:

Verification gates

Before claiming the app is done:

Pitfalls

References