Hy4 Flash: How to control image collaging and batch splitting when processing large batches of product images?

Summary: This article explains how dense a collage should be when using Hy4 Flash for batch product-image recognition, how many images to pack into one request, and how to split batches and rerun missing items when something goes wrong.

Bottom line up front: Start by separating fields. Coarse labels such as color, main-image type, and whether packaging is visible can be screened first with low-density collages. Fine-grained fields such as net content, model number, expiration date, and ingredient order should use standalone image tiles or labels cropped directly from the original image. Collage density and per-batch capacity should both be benchmarked against single-image results and decided using field accuracy, SKU mismatch rate (cross-SKU mix-up rate), and rerun rate. Every request has to clear five gates at once: file, request body, image count, context, and field acceptance. The first gate to hit its ceiling determines where to split the batch.

The applicability conditions need to be stated up front: the image workflow in this article only applies to Tencent’s first-party TokenHub endpoint. The hy4-flash entry in APIYI’s public catalog is a text item; it’s suitable for text-side normalization and review of extracted results. Public sources were checked on 2026-11-30. The canvas dimensions, starting batch tiers, and the 120-item sample in this article are all part of an acceptance design and theoretical worked example. We haven’t run these tests, and we don’t report measured results here.

hy4-flash-product-image-batching-grid-split-en-image-0

Hy4 Flash Product Image Batch Processing Knowledge Map

hy4-flash-product-image-batching-grid-split-en-image-1

Diagram note: this diagram starts with asset ingestion. It first uses the field type to decide whether to go with a collage or separate images, and then the two paths converge on the same gold-standard acceptance step. If acceptance falls short, you go back to the collage step and lower the density; only once it passes do you move on to five-gate batch assembly. After the request returns, you validate rows one by one — failed rows only trigger a re-run of the corresponding images, while passing rows go through text-side normalization and into storage.

Hy4 Flash Product Image Batch Processing Index

  • Section 1 – Entry Points and Hard Limits: Start by pinning down which entry point the images go through and which vendor limits apply. Every worked example later in this guide uses these numbers as its boundary.
  • Section 2 – Asset Inventory: Give each image a traceable identity. This is the shared foundation for later acceptance checks, batch splitting, and reruns.
  • Section 3 – Collage Density: Derive how tightly grid cells can be packed using the minimum readable field set, then lay out the rules for layout and mapping.
  • Section 4 – Gold-Standard Acceptance: Compare three formats — single image, collage, and multi-image — on the same sample batch, and establish which fields each format can reliably cover.
  • Section 5 – Packing Batches Against Five Gates: Take the capacity you validated and put it into a request, then check gate by gate to see which threshold binds first.
  • Section 6 – Request Construction and Reruns: Cover the vendor request structure, failure splitting, idempotent reruns, and text-side validation.
  • Section 7 – Pre-Launch Checklist: Condense everything above into one actionable checklist.

Sections 1 and 2 are reference material you can dip into as needed. Sections 3 through 6 have a dependency order: without the acceptance results from Section 4, the batching in Section 5 has nothing to stand on.

To Know: Hy4 Flash Batch Processing Terminology

Term Quick Explanation
detail precision tier The precision parameter for image blocks. auto is the default, low shrinks an image to within 512×512, and high is for fine-detail recognition
Gold standard A human-labeled, reviewed, and frozen standard answer used to score model output
SKU mismatch (cross-SKU mix-up) Assigning fields from product A’s image to product B — the most dangerous error in collage and multi-image requests
Base64 bloat Converting a binary image to Base64 increases its size by about a third, and that goes straight into the request body
usage.prompt_tokens The input token usage returned by the API, used to measure how much context the images actually occupy
Idempotent write Repeated writes of the same product and same field version keep only one copy, so reruns don’t create duplicate records

1. Hy4 Flash entry points and hard limits

1.1 Image specs for Tencent’s first-party TokenHub

The numbers below all come from Tencent Cloud’s invocation guide and image understanding guide. They are first-party specs, not test results:

  • Model and context: TokenHub’s model ID is hy4-flash. The invocation guide lists a 1M context, a maximum input of 960K, and a maximum output of 64K. In a single request, mixed text and image input share the context, and you also need to reserve output budget in advance.
  • Protocols: It supports image-and-text content in Chat Completions, Responses, and Anthropic Messages formats.
  • Files: Supports PNG, JPEG, WEBP, and non-animated GIF, up to 10 MB per image. For URLs, size is based on the file the server downloads; for Base64, it’s based on the decoded size.
  • Count: Up to 600 images per request, and images in multi-turn history also count. Responses and Anthropic Messages count URL blocks and Base64 blocks together.
  • Resolution: Around 128×128 to 2048×2048 is recommended. Anything over 5500×5500 is rejected, and the image processing scale is roughly capped at 2048×2048.
  • Detail level: Chat and Responses default to auto; low shrinks images to 512×512 or less; use high to read details. The dedicated guide lists original under Responses, but when planning you should still estimate against the scaling constraints.
  • Request body: The general image guide’s table lists the request body limit as 100 MB; Base64 adds about one third.

There’s another easy-to-misread point. The per-image token example in the general guide uses the HY-Vision series. You can use it as a rough order-of-magnitude reference, but for Hy4 Flash engineering budgets, calculate from the usage.prompt_tokens actually returned by that entry point, minus the usage when sending only the fixed text.

1.2 How first-party, open-weight, and APIYI catalog entry points divide the work

The open-weight model card lists a context of 1,048,576. That’s the model-card spec. When self-deploying, you also need to record the weight revision, processor version, server-side multi-image limits, and startup configuration separately, because these can all change the limits above.

The public price list on APIYI apiyi.com marks the hy4-flash row as text, and the endpoint list includes only chat, which means /v1/chat/completions. The only facts this table can prove are the model name, billing group, and endpoint catalog. So all conclusions in this article about image precision and image count apply only to the first-party entry point. The SDK is only responsible for building the request on the client. After the payload enters the service, it’s handled according to the specs of the corresponding route. You can’t infer that an entry point supports images just because client code can write an image block.

Entry point Source Use in this article Do image conclusions apply?
Tencent’s first-party TokenHub Invocation guide, Hy API Guide, image understanding guide Main pipeline for product image recognition Applicable
Open-weight self-deployment Model card Spec reference only Must be verified separately against the self-deployment configuration
APIYI apiyi.com Public price list; hy4-flash is text, endpoint chat Text normalization and review of extraction results Not applicable

2. Hy4 Flash Batch Processing Asset Checklist

The point of the checklist is to make every image and every crop traceable back to its original image — later acceptance checks, batch splitting, and re-runs all depend on it. It’s best to build it in the following order:

  1. Versioned originals: Store originals first in immutable object versions; no later processing should ever overwrite them.
  2. Row-level checklist: Each row records the product ID, variant ID, image ID, image role, original dimensions, orientation, file size, and checksum.
  3. Ingest preprocessing: Correct orientation based on EXIF, detect the true MIME type, and drop empty images.
  4. Duplicates and roles: Establish one-to-many relationships for duplicate files, and at the same time preserve the usage differences among front labels, back labels, side labels, and main images — don’t merge them just because the content looks similar.
  5. Crop traceability: Store cropped pieces separately along with the parent image ID, original pixel coordinates, and transformation parameters, so you can go back to the original image and verify during review.

Once the checklist is built, the “image role” column directly determines routing: main images usually go through coarse labeling, while back labels and side labels mostly contain fine-grained fields.

3. How to Determine the Collage Density for Hy4 Flash

3.1 Derive Cell Size from the Smallest Readable Field

The limit on a collage is set by the smallest field in the image that actually needs to be read, not by how many images you can cram in. The table below shows the theoretical cell width on a 2048-pixel square canvas when margins are ignored. In practice, you also have to subtract spacing, labels, and the padding that comes from preserving aspect ratio.

Collage layout Approx. cell width Scaled digit height when the original is 1600 px wide and digits are 20 px high Suitable fields
1×1 (single-image control) ~2048 No scaling, ~20 Control for all fields
2×2 ~1024 ~12.8 Initial screening for coarse labels
3×3 ~682 ~8.5 Coarse labels; acceptance check required
4×4 ~512 ~6.4 Not recommended for reading numbers

Take 4×4 as an example. When width drives the scaling, a digit that was originally 20 pixels high ends up at only about 6.4 pixels. Even bumping the whole collage up to 4096 pixels doesn’t solve it, because the model’s native processing scale is around 2048×2048, and larger images still get scaled down.

This worked example shows why fine fields are better handled with crops of the label from the original image: a crop keeps only the label area, so at the same processing scale, more pixels are left for the text. What exact pixel height counts as “readable” is something you’ll need to pin down with your own gold standard. The numbers in the table are just for this kind of reasoning.

hy4-flash-product-image-batching-grid-split-en-image-2

3.2 Collage Layout and File Mapping Rules

Arrange the collage in fixed rows and columns. Write a short image ID outside each cell’s border, and preserve margins and the original aspect ratio. Do any cropping on the original image first, and keep the file mapping, for example P07-B-label ← P07-B. That way, any image ID that shows up in the output can be traced straight back to the original.

Try to keep multiple views of the same product in the same batch. Otherwise you’ll end up in the admin panel guessing from filenames which back label belongs to which product. If you need to read the brand from the front and ingredients from the back, require each field to carry its source image ID. Your validation samples should also deliberately place similar variants in adjacent cells, to see whether lid color and net content bleed into the neighboring product. That’s exactly the scenario the SKU mismatch rate is meant to test.

4. Golden Standard Acceptance Design for Hy4 Flash’s Three Forms

This section is an acceptance design. Both the sample size and the thresholds are example values—this article doesn’t actually run this test.

4.1 Samples and Annotation

Build a 120-item example queue out of de-identified original images, evenly covering six scenarios: clear large text, extremely small text, glare, skewed placement, similar packaging variants, and images that are themselves missing fields. Manually annotate each item’s category, color, net content and unit, model number, and readability. For net content, keep both the raw text and the normalized value in two separate fields, so 250 mL doesn’t get mistakenly rewritten as 250 g during string cleanup.

Disputed samples go to a second person for review, after which the original images, annotations, and prompt version get frozen. The sampling set should include both repeat shots of the same product and new packaging for the same SKU. The comparison table should carry a “no borrowing values across versions” flag: if, say, the old version’s net content for a juice and the new version’s ingredients each show up on a separate image, then any result that merges them into a single record is judged wrong.

4.2 Three Comparison Groups

  • Control group: a single image or a single crop, serving as the baseline for all fields.
  • Tiled group: the same set of images assembled into 2×2 and 3×3 mosaics, running only coarse labels, recording the maximum grid size each sample category can tolerate.
  • Multi-image group: each image keeps its own independent image_url block, organized by product, comparing two starting tiers of 8 and 16 images per request.

All three groups use the same field constraints and business ordering. Then run an extra round with shuffled product order, specifically to measure cross-slot leakage. Before comparing batch sizes, lock down the image entry point and precision tier first—otherwise the variables get tangled together.

4.3 Metrics and Launch Thresholds

Metric Calculation basis Example threshold
Field exact match rate Each field scored individually; ingredient order, decimal point, and unit of measure counted separately Coarse labels at least 98%
Model number and dimension correctness Item-by-item verification within the calibration set Zero errors
Cross-SKU attribution error rate Proportion of fields attributed to the wrong product Zero errors
Product row completeness Whether all product rows that should be returned are present Set by the business
Re-run ratio Share of images that need a re-run Set by the business
Cost per qualifying item Amortized only over fully qualifying records, including crop review and human verification Compare across approaches

When tallying, keep “text really is on the image but was missed” separate from “the source image genuinely lacks this field.” The smaller the sample, the more you need to report numerator and denominator category by category. Zero errors is just an observation on the sample—the higher the business risk, the larger the tail sample needs to grow.

Amortize cost only over fully qualifying products. High-density tiling saves on image count, but if it adds crop review and human verification, that cost has to be charged back to the tiled approach—otherwise you’re quietly shifting latency and cost downstream.

Finally, use the same batch of samples to compare whether low and high yield the same coarse labels, and route the small-text errors into label crops with high-precision re-review. When fine-grained fields fall short, lower the tiling density, or switch the corresponding product over to independent images. The acceptance deliverables must spell out all of the following: the tiling tier, crop rules, batch size, and which fields each tier can be used for.


5. The Five Thresholds for Splitting Hy4 Flash Batches

Before assembling a batch, check each image’s dimensions, count, and raw bytes one by one, then check the total encoded bytes per request. All five thresholds take effect at the same time — whichever one hits its ceiling first decides where the batch gets cut.

Threshold What’s checked Vendor basis Common ways to hit the ceiling
1 File Format, size, and resolution of each image 10 MB per image; anything above 5500×5500 is rejected High-pixel back-label photos
2 Request body Total UTF-8 bytes after serialization 100 MB on the general table; Base64 adds roughly a third Large images inlined as Base64
3 Image count New images plus historical images Max 600 per request Accumulated across multi-turn sessions
4 Context Text and image tokens plus output reservation 960K input, 64K output Large batches combined with long outputs
5 Field validation Per-batch capacity from Section 4 Our own gold standard Fine-grained fields shifting out of position

5.1 Request body threshold worked example

Take 12 images at 8 MB each: every one of them passes the single-image threshold, but the Base64 portion alone is about 128 MB. Before you even account for the JSON structure, you’re already past the 100 MB general size table. This example shows that even when context still has plenty of room, you still have to split the batch. Switching to URLs shrinks the request body dramatically, but you’re still constrained by image fetching, link expiration, and original file size — and each image, visual quality, and context still have to be capped together per batch.

5.2 Image count threshold worked example

The image quota is counted by actual encoded blocks. For the same product, there are 6 original images, 4 of which also have label crops — putting them all into one turn gives you 10. If the next turn re-uploads that history and adds 8 more, the new request has to budget for 18. The safer approach is to open short sessions batch by batch and reuse only the business checklist and mapping table — don’t keep dragging the already-extracted original images into new batches.

6. Hy4 Flash Request Construction and Backfill Runs

6.1 First-Party Chat Completions Request Structure

When going through the first-party Chat Completions, you call POST /v1/chat/completions and pass model: "hy4-flash". In a user message’s messages[].content, put “text anchor + image” in order. For example, write the text “Product P07, back label P07-B,” immediately followed by an image_url block, then the anchor for the next image. Responses-format image blocks are written as input_image, with the URL inside that block’s image_url; Anthropic Messages uses type: "image" plus source, using the corresponding form for a URL or Base64.

The code below only demonstrates the structure — the addresses are placeholders. Fill in TokenHub’s access address and key according to the Tencent Cloud console; this article hasn’t run this code:

import os
import openai

# Tencent first-party TokenHub: fill in the access address per the console
tokenhub = openai.OpenAI(
    api_key=os.environ["TOKENHUB_API_KEY"],
    base_url=os.environ["TOKENHUB_BASE_URL"],
)

content = [
    {"type": "text", "text": "逐商品输出一行 JSON:image_id、字段原文、标准化值、unreadable。"},
    {"type": "text", "text": "商品 P07,背标 P07-B"},
    {"type": "image_url", "image_url": {"url": "https://example.invalid/p07b.jpg", "detail": "high"}},
    {"type": "text", "text": "商品 P08,背标 P08-B"},
    {"type": "image_url", "image_url": {"url": "https://example.invalid/p08b.jpg", "detail": "high"}},
]

resp = tokenhub.chat.completions.create(
    model="hy4-flash",
    messages=[{"role": "user", "content": content}],
)
print(resp.id, resp.usage.prompt_tokens)
print(resp.choices[0].message.content)

The model is asked to output one line per product, returning the image ID, the field’s original text, the standardized value, and an unreadable flag. Once the app gets the results, it uses the checklist to do three things: verify the line count, verify attribution, and verify types.

6.2 Failure Splitting and Idempotent Reruns

The app needs to store a stable batch number, the set of image IDs, the prompt version, batch results, and upstream response IDs. When a failure occurs, handle it separately based on the error type:

  • Request body or context errors: bisect by product group, keep the views within a group together, and do atomic accounting first.
  • A single invalid image: fix only that image’s preprocessing, not the entire batch.
  • Network interruption: resubmit the original batch with a new attempt number, and idempotently deduplicate by product and field version on write.
  • Some rows fail validation: for example, if four of five rows pass, persist those four and rerun only the images that failed validation. Rerunning and overwriting the entire batch only expands the error surface.

When aggregating across batches, surface the image ID and source coordinates for manual spot checks. Then attribute the errors to causes such as cells that are too small, images that are hard to distinguish, label misalignment, and retry failures. Those attribution results, in turn, guide the collage profile adjustments in Section 3.

6.3 Field Normalization with the APIYI Text Model

Once image recognition finishes, the extracted results are already text, so this step can go to a text model. hy4-flash in the APIYI catalog is a text entry served through /v1/chat/completions — a good fit for reshaping raw field text into a consistent structure, which your application rules then validate at the end. Just remember: send text only, no image blocks.

import openai

client = openai.OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.apiyi.com/v1",  # APIYI unified endpoint, text only
)

raw = '{"image_id":"P07-B-label","net_content_raw":"250 mL","model_raw":"X-200"}'
resp = client.chat.completions.create(
    model="hy4-flash",
    messages=[
        {"role": "system", "content": "只做字段规范化,不得改动数值与单位,不确定时输出 unreadable。"},
        {"role": "user", "content": raw},
    ],
)
print(resp.choices[0].message.content)
View the full implementation: batching threshold checks + vendor recognition + text normalization
import json
import math
import os
import openai

MAX_FILE = 10 * 1024 * 1024        # 10 MB per image from the original vendor
MAX_BODY = 100 * 1024 * 1024       # 100 MB for a generic request body
MAX_IMAGES = 600                   # images per request (including history)
BATCH_CAP = 8                      # capacity validated in section 4, sample value

def b64_size(n_bytes: int) -> int:
    return math.ceil(n_bytes / 3) * 4

def pack_batches(items, history_images=0):
    """items: [{'product_id','image_id','bytes','inline'}], assemble batches by product"""
    groups = {}
    for it in items:
        if it["bytes"] > MAX_FILE:
            raise ValueError(f"单图超限,先修预处理: {it['image_id']}")
        groups.setdefault(it["product_id"], []).append(it)

    batches, cur, cur_body = [], [], 0
    for pid, imgs in groups.items():
        body = sum(b64_size(i["bytes"]) if i["inline"] else 512 for i in imgs)
        over = (
            len(cur) + len(imgs) + history_images > min(MAX_IMAGES, BATCH_CAP)
            or cur_body + body > MAX_BODY * 0.9
        )
        if cur and over:
            batches.append(cur)
            cur, cur_body = [], 0
        cur.extend(imgs)       # keep views of the same product in the same batch
        cur_body += body
    if cur:
        batches.append(cur)
    return batches

def check_serialized(payload: dict) -> int:
    size = len(json.dumps(payload, ensure_ascii=False).encode("utf-8"))
    if size > MAX_BODY:
        raise ValueError("请求体超限,按商品组二分")
    return size

tokenhub = openai.OpenAI(
    api_key=os.environ["TOKENHUB_API_KEY"],
    base_url=os.environ["TOKENHUB_BASE_URL"],
)
text_client = openai.OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.apiyi.com/v1",  # APIYI text entry hy4-flash
)

def recognize(batch, prompt_version="v1"):
    content = [{"type": "text", "text": f"[{prompt_version}] 每商品一行 JSON"}]
    for img in batch:
        content.append({"type": "text", "text": f"商品 {img['product_id']},图 {img['image_id']}"})
        content.append({"type": "image_url", "image_url": {"url": img["url"], "detail": "high"}})
    payload = {"model": "hy4-flash", "messages": [{"role": "user", "content": content}]}
    check_serialized(payload)
    resp = tokenhub.chat.completions.create(**payload)
    return resp.id, resp.choices[0].message.content

def normalize(row_text: str) -> str:
    resp = text_client.chat.completions.create(
        model="hy4-flash",
        messages=[
            {"role": "system", "content": "只规范字段结构,不改数值和单位。"},
            {"role": "user", "content": row_text},
        ],
    )
    return resp.choices[0].message.content

Tip: You can get the text-side normalization, review prompts, and output format working first on APIYI apiyi.com with the free trial credits for new users, then wire it into the batch pipeline; image recognition itself still goes through Tencent’s native TokenHub.


7. Hy4 Flash Product Image Batch Processing Go-Live Checklist

Use this checklist to decide whether the pipeline is ready to ship:

  1. Every image and every crop can be traced through the manifest back to its source image version and pixel coordinates.
  2. Each mosaic tier has a gold-standard acceptance report stating which fields it can be used for; fine-grained fields aren’t read from high-density mosaics.
  3. Model numbers, units, and cross-SKU attribution show zero errors on the calibration set, with numerators and denominators reported per category.
  4. The batching program checks each of the five gates one by one and can tell you which gate split each batch.
  5. Retries cover only the failed images, and writes are idempotently deduplicated by product and field version.
  6. The image path goes only through the vendor’s native endpoint; hy4-flash on APIYI apiyi.com handles only the text steps.

Once all six are satisfied, weigh the tiers in Section 4 against each other based on retry rate and per-item cost to reach spec.


FAQ

Q1: When Hy4 Flash processes product images, how dense can the mosaic actually get?

There’s no universal number. A 4×4 mosaic on a 2048 canvas gives roughly 512 pixels per tile, so a digit that was originally 20 pixels may end up at only about 6.4 pixels. Coarse labels can be validated starting from 2×2; for fine-grained fields, use label crops. In the end, your own gold standard’s accuracy and cross-SKU mix-up rate are what count.

Q2: The context window is 1M — why still split into batches?

Context is only one of the five gates. Twelve 8 MB images converted to Base64 come to about 128 MB, already past the 100 MB request body limit in the general table. Image count and field acceptance can also hit their ceilings first.

Q3: Can I use APIYI to call Hy4 Flash for image recognition?

According to the public price list at APIYI apiyi.com, `hy4-flash` is listed as text with only a chat endpoint, so the image conclusions in this article don’t apply to that endpoint. We recommend routing images through Tencent’s native TokenHub, then handing the recognized text to APIYI for normalization and review.

Q4: How many tokens does each image consume?

The per-image token examples in the general guide are for the HY-Vision series, so treat them as an order-of-magnitude reference only. For Hy4 Flash, measure at the actual endpoint using `usage.prompt_tokens` minus the usage from sending the fixed text alone.

Q5: How do I choose between the URL approach and Base64?

URL keeps the request body small, but you’ll have to deal with server-side fetching and expiring links — and each image still counts at the file size downloaded. Base64 doesn’t rely on external fetching, but it inflates by about a third, making it easier to hit the request body limit.

Q6: Some products in a batch failed — how do I retry?

Persist the passing rows first, then retry only the images that failed validation. Include a new attempt number when resubmitting, and deduplicate idempotently by product and field version. If you hit a request body or context error, bisect by product group, keeping the views within each group together.

Q7: How can I trial-run the text normalization step on the cheap?

You can sign up at APIYI apiyi.com and use the free test quota to call the text line item `hy4-flash`, with base_url set to `https://api.apiyi.com/v1`. Start with a small set of extraction results to verify that the normalization prompt doesn’t alter values or units.


References

  1. Tencent Cloud Hunyuan Invocation Guide: Hy4 Flash model ID, context window, and input/output limits (updated 2026-11-25)
    • Link: cloud.tencent.com/document/product/1823/132252
  2. Tencent Cloud Hy API Guide: image formats, per-image size, images per request, resolution, and detail precision tiers (updated 2026-11-25)
    • Link: tencentcloud.com/document/product/1300/80695
  3. Tencent Cloud Image Understanding Guide: request body limits, Base64 inflation, and image block syntax across three protocols (updated 2026-11-04)
    • Link: tencentcloud.com/document/product/1300/85589
  4. Tencent Open-Weights Model Card: model card context specifications (accessed 2026-11-30)
    • Link: huggingface.co/tencent/Hy4-flash
  5. APIYI Public Price List: hy4-flash types, billing groups, and endpoint catalog (updated 2026-11-30)
    • Link: docs.apiyi.com/models

Author: APIYI Technical Team
Technical Discussion: Feel free to reach us through the homepage of the APIYI website; more materials are available at the docs.apiyi.com documentation center.

Leave a Comment