Skip to content

Add grok-superimage server-side support, robust SSE streaming/errors, and proxy/imagine fixes#49

Merged
lijirou12 merged 2 commits intomainfrom
codex/migrate-imagine-to-grok-superimage-1.0-63a3ay
Feb 27, 2026
Merged

Add grok-superimage server-side support, robust SSE streaming/errors, and proxy/imagine fixes#49
lijirou12 merged 2 commits intomainfrom
codex/migrate-imagine-to-grok-superimage-1.0-63a3ay

Conversation

@lijirou12
Copy link
Copy Markdown
Owner

Motivation

  • Add a server-controlled "superimage" image model that centralizes image generation parameters and ensures chat output only returns final images.
  • Improve streaming reliability by converting transport errors into SSE error events and handle exceptions during stream-starting calls.
  • Make token retry logic more resilient to transient upstream errors and improve reverse proxy handling for app-chat and websocket imagine flows.
  • Surface new server configuration and admin UI controls for the SuperImage feature.

Description

  • Introduce a new model grok-superimage-1.0 in ModelService and add server-side defaults under a new [superimage] section in config.defaults.toml.
  • Add _superimage_server_image_config() and SUPERIMAGE_MODEL_ID in the chat API and force server-side n/size/response_format for that model; ensure streams for this model only expose final results and preserve original image names for URL outputs.
  • Add SSE-safe streaming wrapper _safe_sse_stream() and _streaming_error_response() to return event-stream error payloads instead of transport 5xx for stream endpoints; wrap streaming returns from chat/image services with these helpers and handle exceptions when starting VideoService or ChatService when stream is enabled.
  • Update image and image-edit stream processors to: only expose final results for chat-format streams, filter/select final images by byte-size, ensure a final chat completion chunk is emitted (even if no content was streamed), and adjust URL naming behavior for superimage outputs.
  • Add transient upstream detection transient_upstream() to retry logic and use it in chat token selection to retry with another token for transient errors; export it from retry utilities.
  • Normalize and handle proxy schemes for AppChatReverse (convert SOCKS schemes to forms suitable for curl-cffi), choose proxy vs proxies appropriately, and adjust timeout selection and logging.
  • Minor renames and imports: get_storage import renamed to resolve_storage in admin API; admin static UI (config.js) extended with superimage fields and select inputs; README updated to document grok-superimage-1.0 and behavioral notes.

Testing

  • Ran the project's test suite with pytest against the modified codebase and existing tests passed.
  • Executed smoke checks of /v1/chat/completions flows (image generation/edit and chat streaming) in a local environment to verify SSE error payloads and final-only behavior for grok-superimage-1.0 streams.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 27, 2026

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

Project Deployment Actions Updated (UTC)
grok2api Ready Ready Preview, Comment Feb 27, 2026 3: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 9109a48 into main Feb 27, 2026
3 of 4 checks passed
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