Skip to content

feat: Add option to generate public asset links for videos#295

Merged
chenyme merged 3 commits intochenyme:mainfrom
fernnguyen:feature/public_asset_after_created
Mar 16, 2026
Merged

feat: Add option to generate public asset links for videos#295
chenyme merged 3 commits intochenyme:mainfrom
fernnguyen:feature/public_asset_after_created

Conversation

@fernnguyen
Copy link
Copy Markdown
Contributor

@fernnguyen fernnguyen commented Mar 7, 2026

Summary

Add a new configurable option video.enable_public_asset that, when enabled, automatically calls the Grok share API after video generation completes to create a publicly accessible link. The final video URL is replaced with a stable public URL (https://imagine-public.x.ai/imagine-public/share-videos/{id}.mp4) that can be accessed without authentication, making it easier to embed or share generated videos.

Changes

  • 功能新增
  • Bug 修复
  • 重构/清理
  • 文档更新
  • 其他

Details:

  • app/services/reverse/media_post_link.py (new) — Reverse interface for POST /rest/media/post/create-link. Handles the Grok share API call, error handling, and 401 token failure recording, consistent with other reverse interfaces in the project.
  • app/services/grok/services/video.py— Added _create_public_link() method to both VideoStreamProcessor and VideoCollectProcessor. The method is called after video generation (and after upscale if applicable) whenenable_public_asset` is enabled. Extracts the video ID from the CDN URL via regex and replaces the final URL with the public asset URL.
  • config.defaults.toml — Added enable_public_asset = true under [video] section.
  • _public/static/admin/js/config.js — Added enable_public_asset entry to the video section of LOCALE_MAP so the toggle appears in the admin config UI.
  • _public/static/i18n/locales/en.json / zh.json — Added translations for the new config field.

Related Issues

N/A

Verification

  • 本地运行验证
  • 单元/集成测试
  • Docker 构建通过
  • 未验证(请说明原因)
  • Started server with docker compose up (built from local Dockerfile)
  • Enabled video.enable_public_asset = true in admin config panel
  • Generated a video via /v1/chat/completions with a video model
  • Confirmed the returned URL is the public asset URL:
    https://imagine-public.x.ai/imagine-public/share-videos/{video_id}.mp4?cache=1 instead of the original authenticated CDN URL
  • Confirmed the field "Public Asset Link" appears correctly in the admin config UI under the Video Config section (both EN and ZH locales)
  • Verified that when enable_public_asset = false, behavior is unchanged and the original video URL is returned as-is

Breaking Changes

  • 有(请说明迁移方式)

The new config key video.enable_public_asset defaults to true in config.defaults.toml. Existing deployments will have this enabled automatically after upgrade. If the Grok share API call fails
for any reason (e.g. network error, 403), the code falls back gracefully to the original video URL — no generation is lost.

@chenyme chenyme merged commit 4818e73 into chenyme:main Mar 16, 2026
7 of 12 checks passed
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