Skip to content

Modality: resolve the media adapter row by provider family, not only the bundled provider id #1927

In progress

Description

@zerob13

What are you trying to do? · 你想完成什么?

Run media operations on providers that are not a bundled catalog row with its own vendor entry:

  • A provider the user created against an OpenAI-compatible endpoint (its id is a UUID): its image and speech models report adapter today, because dim-modality-aimux binds rows by catalog provider id only (vendor::vendor, crates/dim-modality-aimux/src/vendor.rs; Modality A.2: "A created provider's id is a canonical UUID, which matches no row, so its media operations report the adapter reason").
  • Relays whose media models speak another vendor's protocol: the Dim account relay serves minimax-h3 and seedance-*; AiHubMix, New API and Zenmux list doubao-seedance-* and minimax-h3*. The request still goes to the relay with the relay's credential; only the protocol implementation differs.

The previous product did both. It resolved an adapter provider id per provider record (resolveModalityAdapterProviderId):

  • an explicit metadata.modalityAdapterProviderId;
  • else the builtin's own id;
  • else by driver kind: gemini→google, new-api-router→new-api, openai-compatible/openai-responses→openai.

Then it looked up (adapter provider id, model id) exactly, falling back to (adapter provider id, *). Relay aliases for specific models were registered under that family, for example openai/minimax-h3 and openai/seedance-2.0.

What should Dim do? · 你希望 Dim 怎么做?

The built-in adapter chooses its row from the provider's family as well as its catalog id:

  1. A bundled provider with its own row keeps it (today's behavior).
  2. Otherwise the row comes from the provider's protocol family, read from the resolved connection the adapter already receives (ModalityConnection.protocol / driver), for example OpenAI-compatible → the openai package's image and speech models.
  3. A model id can select a different implementation inside a family, so a relay's minimax-h3 uses the vLLM-Omni /videos video model ([feat] openai-compatible 视频模型:/videos 异步任务(vLLM-Omni、New API 与中继) aimux#530) and seedance-* uses the Ark video model ([feat] ByteDance Ark(火山方舟)媒体模型:Seedance 视频与 Seedream 图片 aimux#529), while base URL, headers and credential stay the relay's.
  4. operations stays per model, so a family row never claims a model it cannot run: a chat model under the same relay gets no media operation. The snapshot keeps the Modality: Dim account image models are listed as available options but image.generate is unavailable #1887 contract: no available option the operation would refuse.

This changes a stated rule of Modality A.2, so the design must be updated and agreed first (AGENTS.md: the design document is authoritative). Decisions needed:

  • where the family comes from: connection protocol, driver kind, or an explicit catalog field like the old modalityAdapterProviderId;
  • whether model-id aliases live in the adapter crate or in the catalog entry.

Additional context · 补充信息

Activity

  1. added
    enhancement
    design
    on Nov 20, 2026
  2. self-assigned this
    on Nov 27, 2026
  3. added
    P2
    on Nov 27, 2026
  4. acecloud123 commented on Nov 28, 2026

    @acecloud123

    For a hosted image-generation test case in Dim, AceDataCloud’s GPT Image can return images inline on request. Its default is an image link, which the proposed Dim support doesn’t yet read. https://platform.acedata.cloud/documents/openai-images-generations-integration

  5. yyhhyyyyyy commented on Nov 29, 2026

    @yyhhyyyyyy
    Collaborator

    Design decision record for the first slice (PR #2266)

    This records the architectural decisions #2266 carries, answering the two decision points this issue raises and the reviews on #2266 that asked for the record: what chooses the family, what stays adapter-owned, how recovery answers without a route, and what the later Ark and Seedream routing work must still decide. Three of them, the resolved ModelProtocol as the family's source, the adapter-owned exclusion rules, and the provisional None answer at startup recovery, are submitted here for maintainer confirmation as the accepted decisions of this slice. #2266 is Refs #1927 and Refs #1928 and does not close either issue; the later routing slice will be Fixes #1927 and Fixes #1928 together.

    1. Which fact chooses the family (proposed for confirmation)

    The family is the ModelProtocol that Provider resolves for each model. Provider derives one route per model id (routes), carries it on the selectable-for-modality snapshot (selectable_modality_models), and hands the connection's protocol to the adapter on every submit and wait (startup recovery has no connection and passes none). No catalog field like the old modalityAdapterProviderId is added.

    Precedence inside the adapter's binding: a provider whose id names a built-in VENDORS row resolves to that row whatever the protocol says, and a row never falls back. A rowless provider enters the family fallback only when the whitelist admits it (eligible_for_fallback): a created provider's canonical lowercase UUID, the Dim account relay, or one of the two aggregator gateways this build carries contract tests for (aihubmix, zenmux). Every other rowless bundled id reports the adapter reason rather than answering generic endpoints its vendor never documented, because the vendors behind those ids document neither the endpoints nor the response shapes the compatible packages can consume.

    In the family fallback, only the OpenAI-compatible family carries media: video generation and the image operations go to the openai-compatible package, and speech synthesis and transcription go to the openai package, the only aimux package serving them for this family. A model whose protocol is another family (for example Anthropic or Gemini) reports adapter and lists no media operation.

    2. Who owns the model routing rules (proposed for confirmation)

    They live in the adapter crate, crates/dim-modality-aimux:

    • The word-family exclusions: a video model whose id names the Ark word family (seedance or doubao-seedance as a word in the id, split case-insensitively on ., /, _ and - by in_word_family) is refused by operations, submit and wait alike, because the Ark video API is a different route from the compatible family's /videos (is_ark_video_model); an image model whose id names the Seedream word family (is_seedream_image_model) is refused by the generic image fallback alone, because a Seedream endpoint answers image URLs by default while the compatible package reads inline b64_json alone. The Dim account relay's image generation is not part of the generic fallback, so it keeps the OpenAI package for these models as for any other.
    • The catalog verification on the whitelisted gateways is adapter-owned as well: a cataloged image entry on aihubmix or zenmux is refused unless its endpoint documentation proves the inline shape (catalog_image_verified). The admitted entries are the ids whose tail names the inline-answering prefixes plus the aihubmix entries whose published per-model endpoint schema lists the inline response value; an entry the gateway's own schema service answers model_not_found for is refused whatever its family documents. The audit of the merged catalog, deprecated entries included, splits the fifty five aihubmix image entries into thirty available (twenty three schema-verified, plus seven gpt-image-* ids whose gateway documentation states base64 by default), six Seedream-family ids, sixteen entries whose documentation verifies no inline shape and three more refused because the schema service answers model_not_found for them, and the fourteen zenmux entries into six available (all gpt-image- prefixed) and eight unavailable. An entry whose documentation later proves the inline shape is restored one at a time.
    • Recognition in the Provider layer is a different table from routing, deliberately: the recognizer's whole-word rules (seedance, or minimax and h3 without image) decide which undeclared entries serve video.generate, while the router's exclusions decide what the family binding can execute, and the two can disagree, so a recognized seedance video stays refused on the routing side. The only shared piece is the word-family predicate itself, so the two layers cannot disagree about what a word is. The comments in modality_operations and provider-management 3.6 state this.
    • The alias mapping that the old product registered per family (for example openai/minimax-h3) has no counterpart in this slice: no alias is claimed runnable, and the catalog carries no per-model alias field. Where per-model mapping will live is one of the open questions below; this slice only decided that the exclusions above are adapter code.
    • No matched_model_id is added to the connection or the snapshot: the adapter reads the model id the job already carries.

    3. The provisional answer at recovery (proposed for confirmation)

    A blocking operation never survives a restart: it carries no handle, so a restart leaves it interrupted (A.2's statement for an adapter with no handle; see the module comment of the adapter, lib.rs). Video is the operation a restart resumes, and the task record carries no route. The engine deliberately does not re-resolve a connection to answer recovery's serving question; it asks the recorded adapter with None for the protocol (record_serves).

    In this slice, the adapter's binding treats None as the compatible family (the parameter and the match): the family answers as the compatible one would, while vendor rows, the whitelist and the word-family exclusions still apply, since they need no protocol. The consequence surfaces in the resumed wait: it re-resolves the binding with the live connection's real protocol (wait_video), and a route that does not match ends the task with the error the adapter returned, which the engine records under the adapter's own error code (wait_and_settle). The behavior is pinned by the engine test recovery_resumes_a_video_task_it_never_re_reads_the_route_for in crates/dim-modality/tests/modality_flow.rs. Whether the record should carry enough of the route for recovery to answer exactly is open and listed below.

    4. What the later Ark and Seedream routing work must decide (open)

    1. Per-model routes: which ids route to the Ark video implementation and the Seedream image implementation inside the compatible family, and whether that mapping stays in the adapter crate or becomes catalog data. Until then the word-family exclusions keep these models unavailable rather than misrouted.
    2. The parameter schema per route: operations currently returns one uniform schema per operation for every model of the family; the per-model routes need their own params_schema (Ark's video API takes a resolution enum, not the pixel dimensions the generic schema declares), and how per-model schemas are produced and surfaced is undecided.
    3. Downloading URL-shaped image results: the compatible image binding accepts only inline b64_json today. The binding now asks its gateway for inline bytes by default, which covers gateways that honor response_format; endpoints that ignore the field and answer data[].url alone still depend on upstream aimux support for downloading URL image responses.
    4. Acceptance of the Ark path on the Dim account relay with the relay's real credentials, planned for the routing slice.
    5. Speech synthesis and transcription on the Dim account relay carry no per-model route or exclusion in the first slice and remain pending verification: removing the relay's image-only vendor row lets them resolve to the openai package through the family fallback, and they have not been exercised against a real relay.
    6. The whitelisted gateways' catalog verification: whether the zenmux gateway forwards response_format to non-OpenAI upstreams is undocumented for every non-prefixed row. Two of the eight unavailable zenmux entries, openai/gpt-5.4-pro and openai/gpt-5.5-pro, are conversational models mislabeled as image-generation upstream, so they restore by their declaration being corrected rather than by any schema verification; the remaining six route to non-OpenAI upstreams and restore one at a time, each once its inline response through the gateway is confirmed, and the aihubmix entries restore one at a time as their schemas document the inline shape.

    5. The compatible image binding's request shapes (state after this slice)

    The compatible fallback's package reads inline b64_json alone, so the binding sends response_format: "b64_json" through the same provider options that carry outputFormat (image_options). A caller's own response_format on this binding may only request the inline format itself: any other value, url above all, is refused as invalid input in submit before the job is accepted and again in wait before any progress (check_image_response_format), so the refusal sends zero provider requests, on the top-level and the openaiCompatible namespaced spellings alike. A caller that explicitly requests the inline format passes the check on every route; where it is forwarded it reads its image back. The Dim account relay never takes this path: its image binding is the openai package, which asks for inline bytes on its own. A caller's outputFormat reaches the wire under the spelling the package documents: output_format on the compatible binding, which forwards its provider options verbatim.

    One model-id exception exists, and it is where a gateway report on this issue lands. Model ids whose tail after the vendor namespace starts with gpt-image- or chatgpt-image- send no response_format through the compatible fallback (answers_inline_bytes_by_default): the same prefixes the aimux openai package omits the field for, applied to the id tail after the vendor namespace rather than the full id, because the real OpenAI and Azure endpoints reject response_format for these models with an HTTP 400, and not asking keeps the inline results that pass-through gateways already return unchanged. The omission is total on these routes: a caller that explicitly requests the inline format, on either spelling, sees the redundant value dropped with the default, because a strict GPT Image endpoint rejects the field's presence and the answer is the same bytes without it; the strict contract is pinned by a_strict_gpt_image_endpoint_never_sees_response_format in crates/dim-modality-aimux/tests/adapter.rs. The same exception marks where this slice's limit sits. A commenter on this issue reported a hosted gateway whose GPT Image can return images inline on request but whose default is an image link. On the state of this slice that combination still fails: the model id matches the prefix exception, so Dim does not ask for inline bytes, the gateway falls back to its default link shape, and the compatible package reads no image in it. This combination is a settled limitation of this slice, not a solved problem, and there is no caller-side workaround: the explicit inline value is omitted on these routes for the same strict-endpoint reason, so the combination waits on upstream aimux support for downloading URL image responses. The test an_inline_answering_model_id_sends_no_response_format_through_the_family in crates/dim-modality-aimux/tests/adapter.rs pins the current behavior.

    6. MiniMax H3 on this slice

    The minimax-h3 video rows stay available end to end on the whitelisted gateways, exactly as the corrected catalog rows before this slice, and a user-configured compatible relay keeps serving MiniMax H3 video and image models through the family fallback unchanged. The only MiniMax entries this slice refuses are the two cataloged zenmux rows minimax/minimax-h3-image and minimax/minimax-h3-image-highspeed, and not for any MiniMax-specific reason: the zenmux image documentation is written as a pass-through of the OpenAI Images API, so whether the gateway forwards response_format to a non-OpenAI upstream is undocumented for those rows exactly as for every other non-prefixed zenmux row. The upstream MiniMax image API itself documents an inline response value; what is undocumented is only the gateway pass-through.

    7. Limits of this slice, stated as they are

    An endpoint that ignores response_format and answers data[].url alone is still unreadable and reports no images after HTTP 200 (image_output); downloading such URLs depends on upstream aimux support. Video rows typed chat with no stated output (the wan, kling, sora and pixverse rows) are not retyped in this slice and stay unrecognized, and rows whose declared kind contradicts their output, such as the six zenmux entries typed image-generation with a video output, serve nothing until their declaration is corrected. All verification of this slice ran against mock endpoints and fixture catalog rows; no live relay was exercised.

    The provider's configured endpoint, headers and credential stay exactly as configured in every family resolution: the binding selects only the aimux package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2designenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions