fix: use app-chat REST as primary image generation, fallback to ws_imagine#374
Merged
chenyme merged 4 commits intochenyme:mainfrom Mar 23, 2026
Merged
Conversation
…ck to ws_imagine The WebSocket endpoint `wss://grok.com/ws/imagine/listen` has been deprecated by Grok, causing all image generation requests to fail with `rate_limit_exceeded`. This change: - Adds `_stream_app_chat` and `_collect_app_chat` methods that use the app-chat REST API (via `GrokChatService`) with `imageGen` tool override for image generation - Makes app-chat the primary path for both streaming and non-streaming image generation - Falls back to ws_imagine only when app-chat fails with a non-rate-limit error - Adds `request_overrides` parameter to `GrokChatService.chat()` and `AppChatReverse.build_payload()` to support `imageGenerationCount` and `enableNsfw` - Reuses existing `ImageStreamProcessor` and `ImageCollectProcessor` from image_edit module for processing app-chat image responses Fixes image generation that was broken for all users after Grok deprecated ws_imagine.
…ng, extract markdown images image_edit.py: - Remove VideoService/parentPostId dependency (no longer needed) - Use file_attachments instead of imageEditUri for image upload - Use fixed grok-4 / MODEL_MODE_AUTO for edit upstream - Add image_id to stream events for frontend waterfall compatibility app_chat.py: - Add robust _read_error_body() for non-200 upstream responses - Log content-type and body on failure for better debugging chat.py: - Extract image URLs from markdown syntax in message content - Deduplicate collected image URLs
|
Hurry up and release it, buddy. |
|
Video generation is having the same issue. |
Contributor
Author
Here's my fork with Docker support, feel free to use it: https://github.com/JinchengGao-Infty/grok2api |
Contributor
Author
That's a separate issue — free accounts can't generate videos anymore. |
Closed
piexian
added a commit
to piexian/grok2api
that referenced
this pull request
Mar 22, 2026
上游来源与合并方式: - chenyme#366 chenyme#366 :手工移植 usage 估算与 responses usage 映射,按当前主线重接 chat/responses 接口,没有直接套用原 patch。 - chenyme#374 chenyme#374 :参考原始思路改为 app-chat 单链路接入,移除已不存在的 ws 回退,并补齐 request_overrides。 - chenyme#375 chenyme#375 :参考原始思路重写视频续写与 token 清理,不使用 localhost 自调用,直接复用现有 app-chat 请求链路,并处理 email-domain-rejected。 - chenyme#336 chenyme#336 :手工合并多图参考视频支持,保持旧 image_reference/image_url 兼容,仅在多图或 @图N 场景启用新链路。
Do you know any free alternative to Grok that can generate videos like this? |
|
貌似无法渲染(cherrystudio) |
|
@JinchengGao-Infty 貌似无法渲染(cherrystudio) 还需要配置什么? |
Contributor
Contributor
Author
配置管理 -> 启动地址,填自己的 |
|
openclaw 里可以使用生成图片吗? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
wss://grok.com/ws/imagine/listenhas been deprecated by Grok, causing all image generation requests to fail withrate_limit_exceedederrorsGrokChatServicewithimageGentool override), and keepsws_imagineas a fallbackChanges
app/services/grok/services/image.py_stream_app_chat()and_collect_app_chat()methods for app-chat based image generation_app_chat_request_overrides()helper forimageGenerationCountandenableNsfwgenerate()to try app-chat first, then fallback to ws_imagine on non-rate-limit errorsImageStreamProcessor/ImageCollectProcessorfromimage_editmoduleapp/services/grok/services/chat.pyrequest_overridesparameter toGrokChatService.chat()to pass through custom request fieldsapp/services/reverse/app_chat.pyrequest_overridesparameter tobuild_payload()andrequest()Test plan
/v1/images/generationsendpoint (both stream and non-stream)/v1/chat/completionswith image modelRelated Issues
Nothing
Verification
Breaking Changes