Skip to content

Add grok-superimage server-side config, robust SSE streaming errors, transient retry and proxy handling#48

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

Add grok-superimage server-side config, robust SSE streaming errors, transient retry and proxy handling#48
lijirou12 merged 2 commits intomainfrom
codex/migrate-imagine-to-grok-superimage-1.0-fxv5c7

Conversation

@lijirou12
Copy link
Copy Markdown
Owner

Motivation

  • Introduce a server-controlled SuperImage model mode so grok-superimage-1.0 can have centralized n/size/response_format defaults and stricter streaming behavior for chat completions.
  • Make streaming endpoints more robust by emitting SSE error events instead of transport-level 5xx failures so clients receive structured error payloads during streams.
  • Improve resiliency when calling upstreams by retrying on transient upstream errors with alternative tokens and by normalizing/handling reverse proxy settings for app-chat requests.

Description

  • Added a new model entry grok-superimage-1.0 to ModelService and a server-side config loader _superimage_server_image_config() that reads [superimage] config (n, size, response_format) and forces those values for the SuperImage model.
  • Updated validation and request handling to use the server-side image config when request.model == SUPERIMAGE_MODEL_ID and ensured streaming for SuperImage only returns final images (no intermediate previews).
  • Implemented safe SSE streaming helpers: _safe_sse_stream() to wrap AsyncIterable streams and emit structured SSE error events on exceptions, and _streaming_error_response() to return a one-shot SSE error response for errors raised before streaming starts; wrapped image/video/chat streaming usages with these helpers.
  • Image and image-edit stream processors now suppress partial preview chunks for chat-format streams, track whether any chat chunk was emitted, and emit a final empty chat chunk plus data: [DONE] when needed to ensure the stream completes cleanly.
  • Added transient_upstream() to the retry utilities and integrated it into chat retry logic so transient upstream errors (HTTP 408/5xx, timeouts, connection resets, etc.) will try alternative tokens if available.
  • Improved reverse app-chat proxy handling by normalizing SOCKS schemes (socks5->socks5h, socks4->socks4a), selecting proxy vs proxies for curl_cffi based on scheme, and adjusted timeout logic to prefer chat.timeout but fallback to video/image when unset.
  • Miscellaneous: renamed get_storage import to resolve_storage in admin API to avoid a name clash and renamed admin route get_storage to get_storage_mode; added orjson import where used; added UI support for superimage fields in app/static/admin/js/config.js and default config entries in config.defaults.toml; updated readme.md to document grok-superimage-1.0 behavior.

Testing

  • No automated tests were added for these changes and no CI test suite was executed as part of this rollout.

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 1:07pm

@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 a39b650 into main Feb 26, 2026
5 checks passed
@lijirou12 lijirou12 deleted the codex/migrate-imagine-to-grok-superimage-1.0-fxv5c7 branch February 26, 2026 13:07
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