sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

Group model allowlist: exact entries are admitted but never listed in /v1/models or the Codex catalog, so new models must wait for a release

Open HuntercodeT opened this issue 2 months ago • 1 comments

Summary

An exact (non-wildcard) entry in a group's model_allowlist is admitted by the gateway but never listed in GET /v1/models or the Codex catalog (GET /v1/models?client_version=…) unless that model already exists in the listing source. When the source falls back to the compiled-in openai.DefaultModels, admins have no way to surface a newly released model until a new Sub2API release ships.

Scenario

Upstream released gpt-6-sol / gpt-6-luna (see #7514). To enable them the same day, I:

  1. added gpt-6-sol and gpt-6-luna (exact names, no *) to the group's model_allowlist.models;
  2. added identity mappings (gpt-6-sol → gpt-6-sol) to the group's OpenAI accounts.
Request Result
POST /v1/responses with model=gpt-6-sol ✅ 200, billed normally
GET /v1/models ❌ gpt-6-sol missing
GET /v1/models?client_version=0.156.0 (Codex catalog) ❌ missing — not selectable in Codex /model; users must hard-code model = "gpt-6-sol" and get Model metadata … not found

The same allowlist entry is honored for admission but ignored for listing. The only path today is waiting for openai.DefaultModels to be updated and released (currently PR #7509).

Environment: v0.2.7, platform=composite group with 11 OpenAI OAuth accounts (7 with openai_passthrough=true). Plain openai groups go through the same FilterForListing call for /v1/models and are affected the same way.

Root cause (v0.2.7)

  1. The listing source is often the compiled-in default list. GatewayService.GetAvailableModels (service/gateway_service.go:1378) returns nil when any OpenAI account in the group has passthrough enabled (:1422) or when no account has a model_mapping (:1439). Callers then fall back to defaultModelIDsForPlatform → openai.DefaultModels (pkg/openai/constants.go:20). Composite groups do the same in compositeAvailableModels (handler/gateway_handler.go:1265, :1278).
  2. The allowlist can only intersect, never add. GroupModelAllowlist.FilterForListing (service/group_model_allowlist.go:154) emits an exact entry only if it is already present in source (allowlistSourcePatternAllowsModel). Allows (:95), on the other hand, admits exact entries without looking at any source.

The comment on allowlistSourcePatternAllowsModel states the intended invariant: "admitted ⇒ listed" (「准入允许 ⇒ 列表可见」). That invariant does not hold for exact entries that are missing from the source.

Proposed fix

Option A (preferred, no schema change): in FilterForListing, always emit exact (non-*) entries, even when they are absent from source. Wildcard entries keep expanding only against source, so nothing is invented from patterns.

  • Restores the "admitted ⇒ listed" invariant.
  • An exact name written by an admin already means "make this model available"; listing it matches intent.
  • Only affects groups that have the allowlist enabled and contain exact names absent from the source — and those models are already callable.
  • Gives admins a release-independent way to expose new models, which is the common pain behind #5252 and #1867.

Option B: keep FilterForListing as-is and add a separate group field (e.g. extra_models) that is merged into the listing source for /v1/models and the Codex catalog. More explicit, but adds a field and UI.

Reproduction

# 1. Enable the allowlist with an exact model that is NOT in openai.DefaultModels but works upstream
PUT /api/v1/admin/groups/:id  {"model_allowlist":{"enabled":true,"models":["gpt-5.5","gpt-6-sol"]}}
# 2. Have at least one OpenAI account with extra.openai_passthrough=true (or no account with model_mapping)
# 3.
curl -H "Authorization: Bearer $KEY" "$BASE/v1/models"                        # only gpt-5.5
curl -H "Authorization: Bearer $KEY" "$BASE/v1/models?client_version=0.156.0" # only gpt-5.5
curl -H "Authorization: Bearer $KEY" "$BASE/v1/responses" \
  -H 'Content-Type: application/json' -d '{"model":"gpt-6-sol","input":"hi"}' # 200

A related but separate problem — passthrough accounts causing the whole group to ignore model_mapping — is tracked in #6647; I'll add details there.

If maintainers agree with Option A, I'm happy to send a PR (change FilterForListing, plus unit tests for "exact entry absent from source is listed" and "wildcard entry does not expand beyond source").

HuntercodeT avatar Sep 23 '26 01:09 HuntercodeT

Correction: I'm withdrawing Option A.

I checked it against our own group before writing the PR, and it would do more harm than good. Allowlists in practice are broad "permitted names" lists, much wider than what the account pool can actually serve. In that group, the allowlist has 117 entries and the current Codex catalog has 56 models. Under Option A, 61 extra models would be listed that no account in the group can serve:

  • Claude/Grok/GLM/Kimi/Qwen/MiniMax entries for platforms the group has no accounts for;
  • gpt-image-* / gemini-*-image entries, which FilterCodexModelIDsForGroup deliberately strips from the Codex catalog. Option A would put them back.

So the existing rule that exact entries must be present in the source is correct. I also overstated the "admitted ⇒ listed" point: that comment is about the source-pattern matching rules, not a promise that every allowlist entry is listed.

The actual root cause of the gpt-6-sol case is the listing source. A single passthrough account discards every other account's model_mapping. That is fixed in #7526: passthrough accounts are now treated like unmapped accounts and contribute the default set, while mappings on ordinary accounts still reach /v1/models and the Codex catalog. With that change, advertising a new model only needs a mapping on a non-passthrough account plus the allowlist entry, without waiting for a release.

Feel free to close this in favor of #7526 / #6647.

HuntercodeT avatar Sep 23 '26 03:09 HuntercodeT