Skip to content

feat(proxy): add video/speech/music/sound-effects media endpoints#14

Merged
VickyXAI merged 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feat/media-endpoints
Jul 4, 2026
Merged

feat(proxy): add video/speech/music/sound-effects media endpoints#14
VickyXAI merged 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feat/media-endpoints

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Collaborator

What

The sidecar only exposed /v1/images/generations, so OpenAI-compatible clients (LiteLLM) could not reach the gateway's video/audio models — a call to xai/grok-imagine-video 404'd at the proxy even though the gateway supports it.

Adds four OpenAI-shaped media routes, mirroring the existing image route:

  • POST /v1/videos/generations — video (default xai/grok-imagine-video; async submit+poll, settles only on completion)
  • POST /v1/audio/speech — OpenAI-compatible TTS
  • POST /v1/audio/generations — music
  • POST /v1/audio/sound-effects — sound effects

Adapter: video/music/speech/sound_effect async wrappers that dispatch Base (dedicated VideoClient/MusicClient/SpeechClient) vs Solana (unified SolanaLLMClient); the sync SDK clients run in the shared thread pool, same pattern as images.

Requires

blockrun-llm with Solana media support — BlockRunAI/blockrun-llm#16 (SolanaLLMClient.video etc.). Merge/release that first.

Validation

Tested live on Solana mainnet through the adapter path: grok-imagine-video, speech (flash + turbo), sound-effects, and music all delivered real media URLs; failed video settlements (transient transaction_simulation_failed) correctly took no payment.

Purely additive (307 lines, no deletions); branched off main.

The sidecar only exposed /v1/images/generations, so OpenAI-compatible clients
(LiteLLM) could not reach the gateway's video/audio models — e.g. a call to
xai/grok-imagine-video 404'd at the proxy even though the gateway supports it.

- Add POST /v1/videos/generations, /v1/audio/speech, /v1/audio/generations,
  and /v1/audio/sound-effects, mirroring the existing image route.
- Adapter: video/music/speech/sound_effect async wrappers with Base (dedicated
  VideoClient/MusicClient/SpeechClient) vs Solana (unified SolanaLLMClient)
  dispatch; sync SDK clients run in the shared thread pool.

Requires blockrun-llm with Solana media support (SolanaLLMClient.video etc.).
Validated live end-to-end on Solana mainnet via the adapter path.
@KillerQueen-Z KillerQueen-Z force-pushed the feat/media-endpoints branch from 113f973 to cc046f8 Compare July 3, 2026 20:39
@VickyXAI VickyXAI merged commit 52181d7 into BlockRunAI:main Jul 4, 2026
VickyXAI added a commit that referenced this pull request Jul 4, 2026
Review follow-up fixing everything flagged on the media-endpoints PR:

- ValueError -> 400 on ALL media routes via a shared _media_endpoint
  helper (was video-only; music with lyrics + default instrumental=True
  500'd instead of returning the SDK's clear message)
- Solana media on a pre-#16 blockrun-llm now degrades to a clear 501
  (upgrade hint) instead of an AttributeError 500; pyproject notes the
  floor bump owed when the SDK release ships
- Long media (video 60-900s, music 60-210s) moved to a dedicated
  8-thread pool (BLOCKRUN_LONG_MEDIA_THREADS) and all media routes to
  their own semaphore (BLOCKRUN_MEDIA_MAX_CONCURRENT, default 20) so a
  video burst can no longer starve images or brick chat/messages
- Client-supplied budget_seconds/timeout clamped to the 900s server cap
  (was forwarded verbatim: one request body could pin a worker thread
  for a day); _run_media wraps every call in asyncio.wait_for so the
  coroutine + permit always release even if the SDK thread wedges (504)
- Media calls now audit-log via log_proxy_call and surface the in-body
  settlement txHash as x-blockrun-settlement (paid media traffic was
  invisible to spend reconciliation)
- asyncio.get_running_loop() in _run_media; VIDEO_PARAM_KEYS single-
  sourced in the adapter; media client getters collapsed to one cached
  factory; /v1/responses added to the module endpoint catalog
- tests: full negative-path suite for all 5 media routes (incl. the
  pre-existing image route) + adapter dispatch/clamp/guard/ceiling tests

Co-authored-by: 1bcMax <viewitter@gmail.com>
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