Skip to content

feat(api): support Grok subscription image generation - #15423

Merged
diegosouzapw merged 7 commits into
cheaper-inference:release/v3.8.52from
QuangBlue:feat/grok-subscription-images
Oct 7, 2026
Merged

diegosouzapw merged 7 commits into
cheaper-inference:release/v3.8.52from
QuangBlue:feat/grok-subscription-images

Conversation

@QuangBlue

@QuangBlue QuangBlue commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Grok subscription OAuth connections previously could not resolve image models through /v1/images/generations. Register Grok Imagine Image 2.0 and the existing Imagine models for grok-cli/gc and xai-oauth/xao, and add Image 2.0 to xAI API-key connections. Requests reuse the existing OAuth refresh, persistence and account-selection path and dispatch to the xAI image endpoint.

Translate OpenAI pixel sizes into xAI aspect ratio/resolution, preserve explicit native options, map high/hd to medium and standard to low, and validate options before dispatch. Older Imagine models reject the unsupported quality option. Document the callable model IDs and request contract.

Validation

  • Change type: provider / API
  • Final focused image handler, route, registry and credential retry tests: 73 passed on the company main integration branch
  • npm run test:vitest: 54 files / 493 tests passed
  • npm run typecheck:core
  • npm run lint (full repository) and ESLint on all changed TypeScript files
  • node scripts/check/check-api-typecheck.mjs (new diagnostic fixed; existing baseline preserved)
  • npm run check:provider-consistency and npm run check:provider-assets
  • provider-translate-path-golden.test.ts: 2 passed / 1 failed on macOS; the only snapshot differences are existing Copilot user-agent platform strings (linux versus darwin). This PR does not change the chat provider builders or their golden snapshot.
  • npm run check:docs-all
  • Pre-commit and commit-message gates
  • Full npm run test:unit was started and stopped after failures outside the image change. A separate run on unmodified company main (48bcfc9556) reproduced failures in stream-chunk lifecycle, early keepalive logging, Claude cooldown escalation and relay error handling (25 passed / 6 failed). These files and their implementation are unchanged by this PR.
  • CI still has inherited failures: dependency audit in the Lint job (unchanged lockfile), translation drift for docs/architecture/QUALITY_GATES.md, and generated omni-providers skill drift (unchanged generator inputs). The feature guide is a separate document; the API reference translation drift introduced by the initial draft was removed.

Tests Added Or Updated

  • tests/unit/image-xai-subscription.test.ts: provider aliases/catalog, native options, size and quality mapping, invalid inputs and legacy model behavior.
  • tests/unit/image-generation-route.test.ts: API-key and both OAuth providers, catalog visibility, token refresh persistence and validation before upstream dispatch.

Coverage Notes

The new adapter's branches are exercised by deterministic payload tests; route tests cover credential selection, actual dispatch and persisted token rotation. No credentials or generated media are included in this change.

Reviewer Notes

⚠️ base-red inherited: #15306. The baseline failures above remain outside this feature branch. All focused feature checks pass.

Before implementation, a live subscription OAuth call to https://api.x.ai/v1/images/generations with grok-imagine-image-2.0, aspect_ratio: "3:2", resolution: "1k", quality: "medium" and response_format: "b64_json" returned HTTP 200 and an image. Entitlements and quota remain upstream-controlled.

Provider contract: https://docs.x.ai/developers/model-capabilities/images/generation

Quang Blue and others added 6 commits October 3, 2026 13:42
Register the xai-oauth and grok-cli image routes, and remap OpenAI quality
high/hd, only when GROK_SUBSCRIPTION_IMAGES_ENABLED is true. While the flag
is off, the API-key xAI image path stays on the existing request.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 4e1f541 into cheaper-inference:release/v3.8.52 Oct 7, 2026
7 of 9 checks passed
diegosouzapw added a commit that referenced this pull request Oct 7, 2026
Records the Onda B quality drift on the post-squash tip `9214916a`. Product squashes do not carry the baseline.

File-size ceilings inside `frozen`, measured with `split("\n").length`:

- `browser-worker.ts` 4398 → 4467 (#15615)
- `EndpointPageClient.tsx` 2493 → 2531 (#15565)
- `SystemStorageTab.tsx` 1611 → 1619 (#15565)
- `imageGeneration.ts` 3346 → 3377 (#15423, #15513)
- `catalog.ts` 2127 → 2130 (#15701)
- `auth.ts` 3666 → 3668 (#15624)

`node scripts/check/check-file-size.mjs` passed. The legacy string map was not edited.

⚠️ base-red inherited: #15306
diegosouzapw added a commit that referenced this pull request Oct 8, 2026
Drains 9 v3.8.52 tip unit reds: 3 production defects — MCP bundle startup deadlock (async ESM init cycle from #13739; lazy-load cleanModelName), client bundles pulling server-only DB via imageRegistry→featureFlags (#15423; dependency-free resolver bridge, DB override preserved, default OFF), zh-CN/zh-TW glossary violations (#15138/#15092) — plus regenerated route namespaces, env-isolated guide-settings test, auth-test alignments that keep (and tighten to count=2) the loopback/management guards, quota-card guard following #15138 redesign, and stryker listing of 2 tip covering tests. Combined-board validation with #15903: 327/329 on the previously red files, typechecks, lint, 22 gates.
Abhijeet1520 added a commit to Abhijeet1520/OmniRoute that referenced this pull request Oct 18, 2026
cheaper-inference#15423 statically imported isFeatureFlagEnabled into imageRegistry, which
is reachable from "use client" pages via mediaServiceKinds (the cheaper-inference#10692
invariant). That dragged featureFlags → db/core → the server-only graph
into the browser bundle, failing production builds with ~175
Module not found: 'fs'/'async_hooks'/'child_process' errors
(same class as cheaper-inference#13474). The repo's own guard
(client-bundle-no-server-only-10692.test.ts) fails on the current tip.

Dependency inversion, matching the dynamicImageModelSources pattern:
- imageRegistry exports a resolver seam; unregistered (client bundle)
  falls back to the env var only
- registerNodejs() installs the real DB+env reader at server boot

Validated: guard test 4/4 green, grok/xai image tests 6/6 green,
image-generation-route tests 30/30 green, typecheck-core clean,
dashboard typecheck baseline unchanged (0 new errors).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
diegosouzapw added a commit to Kizuno18/OmniRoute that referenced this pull request Oct 27, 2026
…ABLED

Owner decision for cheaper-inference#15305 (option a): the grok-cli image provider joins
the other Grok subscription image routes behind the opt-in flag instead
of being always on.

- Drop the always-on grok-cli entry from IMAGE_PROVIDERS; the Grok Build
  provider now lives only in XAI_SUBSCRIPTION_IMAGE_PROVIDERS, so with the
  flag off gc/ is not an image provider (grok-subscription-images-flag-off
  keeps passing).
- Build the Grok Build image body with the same buildXaiImageRequest the
  xAI routes use (cheaper-inference#15423): native aspect_ratio/resolution, size mapping,
  Image 2.0 quality and Zod validation stay identical; only the host, the
  CLI token-auth header and the token source differ.
- Tests: grok-oauth-media runs with the flag on and checks the catalog
  split; image-generation-route expects the Grok Build proxy for grok-cli
  (xai-oauth and xai keep api.x.ai); video-job-abort warms the call-log
  recorder the tip added so the abort-latency check measures the abort.
- Docs: grok-cli-media and GROK_IMAGES describe the opt-in and the
  transport difference; the changelog fragment says images are opt-in.

Co-authored-by: Kizuno18 <appdoleo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants