Skip to content

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

Open
fernnguyen wants to merge 2 commits intochenyme:mainfrom
fernnguyen:feature/public_asset_after_created
Open

feat: Add option to generate public asset links for videos#295
fernnguyen wants to merge 2 commits intochenyme:mainfrom
fernnguyen:feature/public_asset_after_created

Conversation

@fernnguyen
Copy link

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

  • New feature
  • Bug fix
  • Refactor/cleanup
  • Documentation update
  • Other

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

  • Local run verification
  • Unit/integration tests
  • Docker build passed
  • Not verified
  • 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

  • None

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.

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.

1 participant