Skip to content

Add grok-superimage server-side image mode; improve streaming error handling and transient retry logic#46

Merged
lijirou12 merged 2 commits intomainfrom
codex/migrate-imagine-to-grok-superimage-1.0-ql75b8
Feb 26, 2026
Merged

Add grok-superimage server-side image mode; improve streaming error handling and transient retry logic#46
lijirou12 merged 2 commits intomainfrom
codex/migrate-imagine-to-grok-superimage-1.0-ql75b8

Conversation

@lijirou12
Copy link
Copy Markdown
Owner

Motivation

  • Introduce a server-controlled image model grok-superimage-1.0 that centralizes n/size/response_format so clients cannot override these for that model.
  • Make streaming endpoints more robust by converting transport/exception failures into SSE error payloads for streaming clients.
  • Improve token retry behavior to handle transient upstream failures by attempting alternative tokens when sensible.
  • Add UI and default config entries for the new superimage server settings.

Description

  • Added grok-superimage-1.0 to the model registry in ModelService and a server-side configuration section [superimage] in config.defaults.toml to control n, size, and response_format.
  • Enforced server-side image config for grok-superimage-1.0 by adding _superimage_server_image_config() and routing image request handling to use the server config when request.model == 'grok-superimage-1.0' in app/api/v1/chat.py.
  • Implemented safe SSE streaming wrappers: _safe_sse_stream() to stream SSE error payloads on exceptions and _streaming_error_response() to return one-shot SSE error responses for early failures in chat.py, and wrapped streaming returns to use these helpers.
  • Prevented chat-stream endpoints from emitting intermediate preview/partial images for chat-formatted image streams by filtering partial stages in ImageWSStreamProcessor and ImageStreamProcessor, and ensured a final empty chat chunk and data: [DONE] are emitted when no final chunk was produced.
  • Added transient upstream detection transient_upstream() in app/services/grok/utils/retry.py and updated token retry logic in ChatService to try alternative tokens on transient errors when alternatives exist.
  • Renamed ambiguous import get_storage to resolve_storage in admin_api/config.py and renamed the endpoint function to get_storage_mode() to avoid naming conflict and improve clarity.
  • Adjusted AppChatReverse timeout selection logic to prefer chat.timeout and fall back to video.timeout/image.timeout when unset.
  • Updated admin UI app/static/admin/js/config.js, added superimage fields and select controls for size and response_format, and updated README readme.md to document grok-superimage-1.0 behavior.

Testing

  • Ran the project's automated test suite with pytest against the modified codebase and existing tests; the test run completed successfully with no failures.
  • Exercised streaming image and chat flows in an integration smoke test to verify SSE error payloads are returned on upstream exceptions and that grok-superimage-1.0 uses server-side n/size/response_format (manual integration assertions in CI), which passed.
  • Ran static linting/type checks and they completed without new issues.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
grok2api Ready Ready Preview, Comment Feb 26, 2026 11:43am

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@lijirou12 lijirou12 merged commit 0724495 into main Feb 26, 2026
5 checks passed
@lijirou12 lijirou12 deleted the codex/migrate-imagine-to-grok-superimage-1.0-ql75b8 branch February 26, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant