-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(videos): add Grok video bridge for non-OpenAI models #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
78109c2
feat(videos): add Grok video bridge for non-OpenAI models
4722563
fix(videos): address Codex P1/P2 + CodeRabbit review findings
5e09f32
fix(videos): encode requestId, defer paidVideoCalls, guard plan! asse…
73cab25
fix(videos): batch-aware artifact pruning + clarify provider key docs
bb54384
fix(videos): web search coexistence, unified timeout budget, VideoBud…
a906923
fix(videos): gate tool_choice on imgPlan, shared deadline signal, buf…
c613b05
fix(videos): pass deadline-bound signal into poll generator
938f25e
fix(videos): deadline abort classification, pruned-path guard, video …
cf76fb1
fix(videos): complete pruned-path guard, skip namespaced aliases, moc…
50bd696
fix(videos): stop hanging ubuntu CI with global setTimeout mock
Wibias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| title: Video Bridge | ||
| description: Generate videos with Grok Imagine Video through a non-OpenAI model. | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| The Video Bridge lets you use xAI's Grok Imagine Video generation through any non-OpenAI model | ||
| routed by opencodex. When enabled, a synthetic `video_gen` tool is injected into the conversation. | ||
| The model calls it like any function tool; opencodex intercepts the call, submits a video generation | ||
| job to xAI, polls until completion, and downloads the result. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - An `xai` provider entry with an **API key** (`ocx login xai` alone is not sufficient — the video bridge requires key auth, not OAuth) | ||
| - A non-OpenAI model as your routed provider (e.g. Anthropic Claude, Google Gemini) | ||
| - opencodex configured to route through the non-OpenAI provider | ||
|
|
||
| > **⚠ Provider key required:** The video bridge only activates when the `xai` provider uses | ||
| > API key auth. Add this to your config: | ||
| > | ||
| > ```json | ||
| > { | ||
| > "providers": { | ||
| > "xai": { "adapter": "openai-chat", "apiKey": "xai-…", "authMode": "key" } | ||
| > } | ||
| > } | ||
| > ``` | ||
| > | ||
| > If you onboarded via `ocx login xai` (OAuth), the provider stays in `authMode: "oauth"` | ||
| > and the bridge silently won't activate. Set `XAI_API_KEY` in the environment **or** | ||
| > hard-code the key as shown above. | ||
|
|
||
| ## Configuration | ||
|
|
||
| Add `videoBridgeEnabled: true` to your `images` config: | ||
|
|
||
| ```json | ||
| { | ||
| "images": { | ||
| "bridgeEnabled": true, | ||
| "videoBridgeEnabled": true, | ||
| "videoBridgeModel": "grok-imagine-video", | ||
| "videoMaxRounds": 2, | ||
| "videoTimeoutMs": 300000 | ||
| } | ||
| } | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| | Option | Default | Description | | ||
| |--------|---------|-------------| | ||
| | `videoBridgeEnabled` | `false` | Master switch. Must be explicitly enabled. | | ||
| | `videoBridgeModel` | `"grok-imagine-video"` | xAI video model id. | | ||
| | `videoMaxRounds` | `2` | Max video-gen rounds before forced final answer. | | ||
| | `videoTimeoutMs` | `300000` (5 min) | Per-video timeout including polling. | | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. opencodex detects a non-OpenAI routed model with `videoBridgeEnabled: true` | ||
| 2. A synthetic `video_gen` function tool is injected into the conversation | ||
| 3. When the model calls `video_gen`, opencodex submits a job to xAI's `/videos/generations` | ||
| 4. The bridge polls the job status every 5-15 seconds, sending heartbeat messages to keep the stream alive | ||
| 5. When the video is ready, it's downloaded to the artifacts directory | ||
| 6. The local file path is returned to the model as a tool result | ||
|
|
||
| ## Supported Parameters | ||
|
|
||
| The `video_gen` tool accepts: | ||
|
|
||
| | Parameter | Type | Range | Description | | ||
| |-----------|------|-------|-------------| | ||
| | `prompt` | string | required | Detailed video generation prompt | | ||
| | `duration` | integer | 1-15 | Video length in seconds | | ||
| | `resolution` | string | `"480p"`, `"720p"` | Video resolution | | ||
| | `aspect_ratio` | string | 7 ratios | `16:9`, `9:16`, `1:1`, `4:3`, `3:4`, `3:2`, `2:3` | | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **xAI only**: Video generation is only available through xAI's Grok Imagine Video API | ||
| - **Asynchronous**: Video generation takes 30-120 seconds | ||
| - **Cost**: Video generation is a paid xAI feature (~$0.05/sec @480p, ~$0.07/sec @720p) | ||
| - **One video per call**: Each `video_gen` call produces one video | ||
| - **Coexists with Image Bridge**: Both bridges can be enabled simultaneously | ||
| - **Web search priority**: When a web search sidecar is active for a turn (non-`runTurn` adapter), the video bridge is skipped — the two cannot run concurrently. A `console.warn` is emitted so you can detect this in logs. | ||
| - **Timeout covers submit + poll**: The `videoTimeoutMs` budget starts before job submission, so the submit call (60 s) and subsequent polling share the same deadline. | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration sample opens both the root object and its
imagesobject but contains only one closing brace, so copying the documented setup produces invalid JSON and prevents opencodex from loading the configuration. Add the missing outer brace and keep the example parseable as written.AGENTS.md reference: AGENTS.md:L96-L97
Useful? React with 👍 / 👎.