afrouter-video
Skill8 starsChanged 3 months agoMITView on GitHub
Video generation through AFRouter /v1/videos (xAI Grok Imagine), async submit-then-poll. Use when the user wants text-to-video or image-to-video.
- Sends data out
In this repository11 other files it gives its agents.
- open-sse/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- afrouter-chatSkill
- afrouter-embeddingsSkill
- afrouter-imageSkill
- afrouterSkill
- afrouter-sttSkill
- afrouter-systemoneSkill
- afrouter-ttsSkill
- afrouter-web-fetchSkill
- afrouter-web-searchSkill
The file
Files
AFRouter — Video Generation (xAI Grok Imagine)
Auth: send Authorization: Bearer $AFROUTER_KEY (required unless the gateway has requireApiKey off). Setup: https://raw.githubusercontent.com/AFG473319/AFRouter/refs/heads/master/skills/afrouter/SKILL.md
BASE="${AFROUTER_URL:-http://localhost:20128}"Requires a connected xAI account in the AFRouter dashboard — either Grok Build OAuth (SuperGrok / X Premium+ subscription sign-in) or a direct xAI API key from console.x.ai. The two are separate auth types with separate billing; the dashboard shows which one each connection uses.
Endpoints (async job flow)
Video generation is asynchronous: the POST returns a request_id immediately, then you poll until the job is done or failed.
| Endpoint | Purpose |
POST /v1/videos/generations | text-to-video / image-to-video |
POST /v1/videos/edits | edit an existing video |
POST /v1/videos/extensions | extend an existing video |
GET /v1/videos/{request_id} | poll job status |
Request fields (passed through to xAI unchanged — see https://docs.x.ai/developers/rest-api-reference/inference/videos):
| Field | Required | Notes |
model | no | xai/grok-imagine-video (prefix is stripped before upstream) |
prompt | yes for T2V | video description |
duration | no | seconds |
aspect_ratio | no | 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3 |
resolution | no | 480p, 720p, 1080p |
image | no | { "url": "https://… or data:image/…;base64,…" } for image-to-video |
video | edits/extensions | { "url": "…mp4" } or { "file_id": "…" } |
Examples
Submit a job:
curl -X POST "$BASE/v1/videos/generations" \
-H "Authorization: Bearer $AFROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"xai/grok-imagine-video","prompt":"A cinematic tracking shot through a neon city at night","duration":8,"aspect_ratio":"16:9","resolution":"720p"}'
# → {"request_id":"abc123"} (response header x-afrouter-connection-id: <id>)Poll until done (echo the connection header back so the same account polls the job):
curl "$BASE/v1/videos/abc123" \
-H "Authorization: Bearer $AFROUTER_KEY" \
-H "x-connection-id: <id from create response>"
# → {"status":"pending","progress":42}
# → {"status":"done","video":{"url":"https://…mp4","duration":8},"model":"grok-imagine-video"}
# → {"status":"failed","error":{"code":"…","message":"…"}}Download: fetch video.url from the done response.
CLI one-shot
afrouter xai video \
--prompt "A cinematic tracking shot through a neon city at night" \
--output video.mp4
# options: --model --duration --aspect-ratio --resolution --image --timeout --port --api-keySubmits, polls with progress, downloads to video.mp4.part, atomically renames on success. Ctrl+C cancels cleanly; non-zero exit on failure.
Notes & limits
- Jobs are account-bound upstream: poll with the same connection that created the job (
x-connection-idheader, value from the create response'sx-afrouter-connection-id). - Creation POSTs are never auto-retried (a retry could create and bill two videos). Only a 401→token-refresh→single-retry is performed, which upstream rejects before job creation.
- Video models are tagged
kind: "video"and are excluded from chat model lists and chat fallback combos. - Grok Build subscription OAuth tokens are sent to the same
api.x.ai/v1/videosendpoints as API keys; whether a given subscription tier includes video-generation quota is controlled by xAI and is not verified by AFRouter — a403/permission_deniedfrom upstream means the connected account has no video access.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

