# Demo: anet × Grok Build — image-to-video (0 LOC integration)

> **Pitch**: Give an anet `grok-build-acp` node an image URL + "animate this into a 5-second video", and it generates an MP4 — with **zero anet-side code changes** and **zero user setup beyond a one-time `grok login`**. The Grok agent calls its built-in `image_to_video` tool (the `imagine` skill), the backend writes the MP4 into the ACP session directory, and anet just surfaces the resulting path back as a reply.
>
> **Author**: 通信SDK马 · **场景文档**: [`docs/scenarios/video-gen-marketing.md`](../../docs/scenarios/video-gen-marketing.md) · **能力探测**: [`docs/research/grok-video-gen-capability-probe.md`](../../docs/research/grok-video-gen-capability-probe.md)

> ✅ **Reliability (verified live on grok-build `0.2.29`, 2026-06-06)**: This demo's flow — **source image → animated video** — uses Grok's built-in **`image_to_video`** tool (part of the `imagine` skill). In a fresh-session live re-test on `0.2.29` (driven via tmux), it **fired cleanly on the first try** and produced a real generative clip in ~1 min — 12 MB, 6 s, 720p, `h264` video + `aac` audio + `mjpeg` cover stream (the authentic backend-model fingerprint, **not** an ffmpeg pan/zoom, which would be video-only). Two clarifications worth knowing:
>
> 1. **It's image-conditioned, not text-to-video.** You must supply a source image. Per Grok's own imagine-skill docs: *"Video starts from an image — there is no text-to-video tool."* A pure "generate a 5-second video from scratch" prompt with no image will be (correctly) declined.
> 2. **Use `0.2.29`+ for this demo.** On the older `0.2.12` alpha the model often struggled to invoke video generation and fell back to a local ffmpeg Ken Burns pan/zoom; the structured `imagine` skill in `0.2.29` resolved this. The `sample/output.mp4` here is an authentic backend-generated clip (aac + mjpeg streams).

## What you get

You get a ~5–6 second 720p MP4 generated by Grok's backend `image_to_video` model from your source image, surfaced back to the dispatcher through commhub — no model API key, no ffmpeg setup, no extra MCP wiring. The motion is real generative diffusion (e.g. water actually moving, foam forming), **not** a camera pan/zoom over a still. (Verified live on `0.2.29`, 2026-06-06 — see the reliability note above.)

**Sample output (5.04s @ 1280×720 @ 24fps, 1.3 MB)**:

![first frame](sample/poster-first-frame.jpg)
![mid frame (~2s)](sample/poster-mid-frame.jpg)

Open [`sample/output.mp4`](sample/output.mp4) to see the full clip. This is the verbatim MP4 the Grok backend produced during the R75 probe — no post-processing.

## Why it's 0 LOC

The Grok agent ships an `imagine` skill whose tools include `image_to_video` (and `image_gen` / `image_edit` / `reference_to_video`). When the agent calls `image_to_video` on a prompt that supplies a source image, the Grok backend generates the clip and writes it into the ACP session directory under `videos/`. The "0 LOC" claim is about the *integration*: no anet-side model wiring, parameter mapping, or MCP server — anet's artifact extractor just surfaces the resulting path. On `0.2.29` this fired reliably (first try, ~1 min) in a live re-test; on the older `0.2.12` alpha the model often failed to invoke video generation, so pin to `0.2.29`+.

anet's `grok-build-acp` runtime already includes a small artifact extractor (`grok-artifact-extractor.ts`) that, on session completion, scans `~/.grok/sessions/<encoded-cwd>/<sessionId>/videos/` and appends the discovered MP4 path to the reply. **That's the entire integration.** No model selection, no parameter mapping, no MCP server, no key management.

## Run it

### 1. One-time setup (if you don't already have Grok CLI)

```bash
# Install Grok Build CLI (any of: brew / npm / direct binary)
# See https://docs.x.ai/docs/grok-build/install

grok --version       # confirm 0.2.x alpha or newer
grok login           # opens browser OAuth, stores token in ~/.grok/auth.json
```

### 2. Spin up an anet grok node

```bash
anet node create grok-vid --runtime grok-build-acp
anet node start grok-vid
# (in a separate shell or via commhub) check it came online:
anet status | grep grok-vid
```

> **Don't connect to a production commhub for the demo.** Use a local hub or your own dev hub. See the project README for spinning up a hub locally.

### 3. Send an image URL prompt

From any anet caller (claude / codex / grok / the dashboard / a script):

```
commhub_send_task(
  alias="grok-vid",
  task="把这张图做成一段 5 秒视频,镜头慢慢拉近,有一点电影感的色调。
        图片: https://images.unsplash.com/photo-1518770660439-4636190af475
        最后把 mp4 路径告诉我。"
)
```

Pick any public image URL you like. The prompt does **not** need to name `image_to_video` or any model — the Grok agent maps "animate this image" to the right imagine-skill tool on its own.

### 4. Receive the MP4 path

When the turn finishes, the reply looks like:

```
已生成 5 秒视频。

生成的视频文件:
- /home/<you>/.grok/sessions/%2Fpath%2Fto%2Fgrok-vid/<sessionId>/videos/1.mp4
```

That path is on the box where the grok node is running. Open it locally, scp it out, or expose it via commhub artifact upload — any of those work.

## What happened under the hood

The LLM took the image URL from your prompt, called the `image_to_video` tool (the `imagine` skill) with the image + a motion prompt, the Grok backend generated the clip in xAI infra, wrote the MP4 to the session directory, and anet's extractor surfaced the path back. All of that is in the existing runtime — you didn't need to write a line of code.

For the verbatim trace (rawInput keys, agent stdout, session ID), see the R75 probe artifacts and [`docs/research/grok-video-gen-capability-probe.md`](../../docs/research/grok-video-gen-capability-probe.md) — that's the report that surfaced the 0 LOC integration finding (it was originally framed as "requires anet-side wiring" until the probe showed the LLM doing it autonomously).

## Caveats

- **Image-conditioned, not text-to-video — see the note at the top.** You must supply a source image; Grok's imagine skill has no text-to-video tool, so a "make a video from scratch" prompt with no image is declined. Use `0.2.29`+ — older alphas (`0.2.12`) often failed to invoke video generation and fell back to ffmpeg pan/zoom.
- The Grok backend decides the duration / style / motion. You can suggest those in natural language; you cannot pass machine parameters through ACP (the `image_to_video` surface is `{image, prompt}`-shaped, not a full model invocation).
- xAI quota applies: each generation burns 1 video-model tick on your Grok account. There is no anet-side throttle yet.
- The MP4 lives inside the grok session directory. anet does not copy it to a content-addressable location automatically. Consumer code can either read the path directly or upload it via commhub artifact APIs (P2 follow-up).

## Pair with Scenario 1

See [`demos/grok-x-search/`](../grok-x-search/) for the basic + advanced X-search demos. Together they cover the two flagship #205 scenarios.

## References

- Scenario doc: [`docs/scenarios/video-gen-marketing.md`](../../docs/scenarios/video-gen-marketing.md)
- Capability probe: [`docs/research/grok-video-gen-capability-probe.md`](../../docs/research/grok-video-gen-capability-probe.md)
- Schema introspection (0.2.12-era): [`docs/tests/p-grok-028-xsearch-acp-probe/report.md`](../../docs/tests/p-grok-028-xsearch-acp-probe/report.md)
- **Live 0.2.29 image_to_video re-verify (current truth):** [`docs/tests/p-grok-0229-image-to-video/report.md`](../../docs/tests/p-grok-0229-image-to-video/report.md)
- RFC-021 §12 "0 LOC qualified": [`docs/rfcs/RFC-021-acp-capability-profile-expansion.md`](../../docs/rfcs/RFC-021-acp-capability-profile-expansion.md)
- Upstream issues: [#205](https://github.com/sleep2agi/agent-network/issues/205) · [#206](https://github.com/sleep2agi/agent-network/issues/206)
