Skip to content

Video bridge: allow a custom video provider (parity with images.provider) #8175

Closed

Description

@bradhallett

Area: Proxy and routing

What are you trying to accomplish?

I use images.provider to route Codex's image_gen tool to a self-hosted, OpenAI-compatible media bridge, and it works exactly as hoped: the provider's baseUrl and API key are honored, and generation fails closed rather than falling back to a hosted account. I want the same choice for video — when a non-OpenAI routed model calls the injected video_gen tool, the submit and poll traffic should reach the video backend of my choice (a local bridge or any vendor exposing an xAI-compatible async video API), so agents can generate video the same way they generate images today.

What prevents this today?

The video bridge pins its destination. In src/images/plan.ts, planVideoBridge resolves the base URL from the hardcoded registry entry for xai and explicitly ignores any provider-level baseUrl override (the code comment reads: "Pin the baseUrl to the registry entry, ignoring any config-level baseUrl override"). That entry's baseUrl is the constant https://api.x.ai/v1 in src/providers/registry/entries-core.ts. So video_gen can only ever talk to xAI:

  • There is no videos.provider equivalent of images.provider (which src/server/images.ts honors live, without a restart).
  • Naming a provider xai and pointing its baseUrl elsewhere does not help — the pin bypasses it.
  • No environment variable overrides it.

The transport itself is one step away from provider-agnostic: src/images/xai-video-client.ts takes auth: { baseUrl, token } as a parameter on both submitVideoJob and pollVideoJob, so honoring a provider's base URL is a small change at the planning layer.

(Verified on 2.97.0, macOS, npm install.)

What should OpenCodex do?

Mirror the images hook: when images.videoBridgeEnabled is true and a new knob such as images.videoProvider names a configured provider, the video_gen tool's submit call (POST {provider baseUrl}/videos/generations) and poll call (GET {provider baseUrl}/videos/{id}) should go to that provider, authenticated with that provider's API key — the same fail-closed, live-honored behavior images.provider gives /v1/images today. With no videoProvider set, keep the current xAI behavior unchanged.

Example usage or interface

{
  "providers": {
    "my-video-bridge": {
      "adapter": "openai-chat",
      "baseUrl": "http://127.0.0.1:8790/v1",
      "apiKey": "local",
      "authMode": "key",
      "allowPrivateNetwork": true
    }
  },
  "images": {
    "videoBridgeEnabled": true,
    "videoProvider": "my-video-bridge",
    "videoBridgeModel": "grok-imagine-video"
  }
}

A non-OpenAI model calls video_gen(prompt, duration, resolution, aspect_ratio); OpenCodex submits to the configured provider's /videos/generations, polls {base}/videos/{id} until status: "done", then downloads video.url into the artifacts directory — identical to the xAI path today, only the destination changes. videoBridgeModel already flows through as the request's model field, so backend-specific model ids need no extra plumbing.

Alternatives or workarounds

None that survive config-only. Pointing a provider named xai at a custom baseUrl fails silently because of the registry pin, and there is no env override. The only working path is patching planVideoBridge to honor the provider's baseUrl — two lines — which every npm update / reinstall of the package reverts, so it is not a real workaround. The wire client's lenient parsing (request_id or id, status or state aliases, video.url or videos[0].url) already suits third-party backends, which is what makes this small hook genuinely useful beyond xAI.

Additional context

  • Parity reference: images.provider is honored live by the relay (no restart), documented in the Image Bridge guide; the video bridge config already lives beside it under images.* (videoBridgeEnabled, videoBridgeModel, videoMaxRounds, videoTimeoutMs), so videoProvider lands naturally in the same block.
  • planImageBridge shares the same registry pin, so one fix at the planning layer — honor the provider's baseUrl when a bridge provider is explicitly configured — could cover both bridges.
  • I built a local bridge implementing the exact submit/poll contract from xai-video-client.ts; against it, only the hardcoded destination blocks the flow, which is what prompted this request.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. added
    enhancement
    install
    provider
    on Nov 4, 2026
  3. Ingwannu commented on Nov 7, 2026

    @Ingwannu
    Owner

    Confirmed on dev (aaa3c20f3f): planVideoBridge takes the key from the provider that findXaiProvider returns. It sends the request to the base URL of the registry's xai entry, not to that provider's baseUrl (src/images/plan.ts:143-145). The in-turn image bridge (planImageBridge, :78-80) does the same. images.provider only selects the backend for the /v1/images endpoint (src/server/images.ts:666), not the in-loop image_gen/video_gen bridges, so there is no existing setting for this.

    Scope: parity with images.provider is reasonable. It does change where a credential is sent, so it needs explicit security review.

    Design points:

    • Keep the xAI behavior. A named videoProvider should use only its own baseUrl and key. An xai provider's key must never follow a baseUrl override; that is what the fixed URL protects today.
    • Loopback bridges. Submit and poll requests to a local bridge should respect the named provider's allowPrivateNetwork, like other provider traffic.
    • Downloads. Fetching the finished video is a separate step. downloadVideoToArtifact (src/images/artifacts.ts:468) accepts a base64 data: URL or a public HTTPS URL only. A local bridge that returns http://127.0.0.1/... as video.url would still be refused. What does your bridge return?
    • Fail closed. If videoProvider names a provider that is missing, disabled or has no key, fail without falling back to xAI, as images.provider does.

    No commitment to implement yet.

  4. lidge-jun commented on Nov 16, 2026

    @lidge-jun
    Owner

    Owner decision (lidge-jun, 2026-11-16): add a videoProvider setting, symmetric with images.provider: only the chosen provider's base URL and key are used, a missing provider fails closed, and an xAI key is never sent to another host. Security review before merge.

  5. bradhallett commented on Nov 16, 2026

    @bradhallett
    ContributorAuthor

    On video.url from my bridge: it returns the upstream vendor's hosted public HTTPS URL — the run output's asset link passed through unchanged (as video: { url: urls[0] }, plus videos: [{ url }] for the lenient parser). So downloadVideoToArtifact accepts it today — no downloader change is needed for this PR.

    Recommendation for the spec: keep the downloader's current rule — video.url is a public HTTPS URL or a data: base64 URL; loopback http://127.0.0.1/... URLs stay refused. If fully-local bridges want loopback delivery later, that is a separate downloader issue with its own allowPrivateNetwork discussion, not scope here.

    Thanks for the decision. I'm preparing a PR against dev: images.videoProvider at the planning layer — the named provider's own baseUrl and key only, fail closed when missing, disabled, or keyless, and an xAI key never sent to another host. Focused regression tests included; the PR will reference the decision comment.

  6. added a commit that references this issue on Nov 16, 2026
    96bae54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinstallprovider

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions