agentleFS
0gfoundation0gfoundation/0g-agent-skills/skills/compute/video-generation/SKILL.md

video-generation

Skill15 starsChanged 58 days agoMITView on GitHub

- Category: compute - SDK: @0gfoundation/0g-compute-ts-sdk ^0.9.0, ethers 6.13.1 - Activation Triggers: "generate video", "text-to-video", "image-to-video", "video generation", "MiniMax", "Seedance" Generate video clips from a text prompt (optionally conditioned on a reference image) using 0G Compute Network providers (serviceType: video-generation). Unlike chat and image generation, this is an asynchronous, three-call flow: submit a job, poll until it completes, then download the MP4. Discover at runtime — never hardcode. At last verification 0G mainnet had two video-generation providers; testnet had none.

  • Reads credentials
  • Sends data out

22 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use consulting-analysis, surprise-me and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • HK-hubSkill

    consulting-analysis

    Use this skill when the user requests to generate, create, or write professional research reports including but not limited to market analysis, consumer insights, brand analysis, financial analysis, industry research, competitive intelligence, investment due diligence, or any consulting-grade analytical report. This skill operates in two phases — (1) generating a structured analysis framework with chapter skeleton, data query requirements, and analysis logic, and (2) after data collection by other skills, producing the final consulting-grade report with structured narratives, embedded charts, and strategic insights.

    Also in 4 projects that use this

  • stophobiaSkill

    surprise-me

    Create a delightful, unexpected "wow" experience for the user by dynamically discovering and creatively combining other enabled skills. Triggers when the user says "surprise me" or any request expressing a desire for an unexpected creative showcase. Also triggers when the user is bored, wants inspiration, or asks for "something interesting".

    Also in 3 projects that use this

  • HK-hubSkill

    ppt-generation

    Use this skill when the user requests to generate, create, or make presentations (PPT/PPTX). Creates visually rich slides by generating images for each slide and composing them into a PowerPoint file.

    Also in 3 projects that use this

  • stophobiaSkill

    github-deep-research

    Conduct multi-round deep research on any GitHub Repo. Use when users request comprehensive analysis, timeline reconstruction, competitive analysis, or in-depth investigation of GitHub. Produces structured markdown reports with executive summaries, chronological timelines, metrics analysis, and Mermaid diagrams. Triggers on Github repository URL or open source projects.

    Also in 3 projects that use this

  • MicrosoftSkill

    podcast-generation

    Generate AI-powered podcast-style audio narratives using Azure OpenAI's GPT Realtime Mini model via WebSocket. Use when building text-to-speech features, audio narrative generation, podcast creation from content, or integrating with Azure OpenAI Realtime API for real audio output. Covers full-stack implementation from React frontend to Python FastAPI backend with WebSocket streaming.

    Also in 3 projects that use this

  • VercelSkill

    vercel-deploy

    Deploy applications and websites to Vercel with a claimable preview. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment". No authentication required - returns preview URL and claimable deployment link.

    Also in 3 projects that use this

  • +1 more from HK-hub

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 19 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ensure the sub-account exists and is acknowledged

    line 90
  2. Very specific:

    Do not: call processResponse()

    line 94
  3. Distinctive:

    Treat generation as asynchronous — submit, poll, then download

    line 100
  4. Distinctive:

    Read live pricing variants before submitting.

    line 101
  5. Very specific:

    Check availableBalance before submitting, since a single clip can cost many 0G

    line 102
  6. Very specific:

    Call processResponse() for a video-generation provider — it throws Unknown service type

    line 109
  7. Distinctive:

    Use ethers v5 syntax

    line 114

“Common” is measured: kept by at least 6 in 10 of the 19 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Video Generation

Metadata

  • Category: compute
  • SDK: @0gfoundation/0g-compute-ts-sdk ^0.9.0, ethers 6.13.1
  • Activation Triggers: "generate video", "text-to-video", "image-to-video", "video generation", "MiniMax", "Seedance"

Purpose

Generate video clips from a text prompt (optionally conditioned on a reference image) using 0G Compute Network providers (serviceType: video-generation).

Unlike chat and image generation, this is an asynchronous, three-call flow: submit a job, poll until it completes, then download the MP4.

Models

Discover at runtime — never hardcode. At last verification 0G mainnet had two video-generation providers; testnet had none.

ModelOutputBilling unit
dreamina-seedance-2-5-260628480p/720p/1080p, 4–30 svideo_token
MiniMax-H32K, 5–15 svideo_second

Both accept text and image input and emit video. Supported request parameters are prompt, seconds, size and input_reference.

Video is by far the most expensive service type on the network. At last check MiniMax-H3 was priced at roughly 1.07 0G per generated second — a 10-second clip is on the order of 10 0G. Always read live pricing before submitting, and prefer the cheapest variant while developing.

Pricing is expressed in variants, because cost depends on resolution.

Types lag the API here. The SDK's ProviderModelInfo['pricing'] declares prompt, completion, image, video, tiered_pricing and cache_token_billing — but not the variants and video_unit fields that video providers actually return. Widen the type locally rather than reaching for any:

interface VideoPricingVariant {
  dimensions?: Record<string, string>;
  unit: 'video_token' | 'video_second';
  unit_price: string;
}

interface VideoPricing {
  video?: string;
  video_unit?: 'video_token' | 'video_second';
  variants?: VideoPricingVariant[];
}

const { models } = await broker.inference.getProviderModels(providerAddress);
for (const m of models) {
  const pricing = m.pricing as VideoPricing | undefined;
  console.log(m.id, pricing?.video_unit); // 'video_token' | 'video_second'
  for (const v of pricing?.variants ?? []) {
    console.log('  ', JSON.stringify(v.dimensions), v.unit, v.unit_price);
  }
}

⚠️ processResponse() is not supported for video

In SDK 0.9.0 the response extractor recognises only chatbot, text-to-image, image-editing and speech-to-text. Calling processResponse() against a video-generation provider throws:

Error: Unknown service type

The job is still billed and settled from the signed getRequestHeaders() headers. What you lose is local fee caching and signature verification, so manage the sub-account balance explicitly — and given the cost per clip, check availableBalance before submitting.

Prerequisites

  • Node.js >= 20
  • @0gfoundation/0g-compute-ts-sdk and ethers installed
  • Funded and acknowledged provider — budget generously, see pricing above
  • .env with PRIVATE_KEY, RPC_URL, PROVIDER_ADDRESS

Quick Workflow

  1. Initialize broker
  2. Find a video-generation provider and read its live pricing variants
  3. Confirm availableBalance covers the clip you are about to request
  4. Ensure the sub-account exists and is acknowledged
  5. POST ${endpoint}/videos → returns a job with an id
  6. Poll GET ${endpoint}/videos/{id} until status is completed
  7. GET ${endpoint}/videos/{id}/content → MP4 bytes
  8. Do not call processResponse()

Core Rules

ALWAYS

  • Treat generation as asynchronous — submit, poll, then download
  • Read live pricing variants before submitting; cost scales with resolution and duration
  • Check availableBalance before submitting, since a single clip can cost many 0G
  • Poll with a sensible interval and an overall timeout
  • Request the smallest size/seconds that answers the question while developing
  • Page listService() in chunks of ≤ 50

NEVER

  • Call processResponse() for a video-generation provider — it throws Unknown service type
  • Expect the MP4 in the submit response — you get a job id
  • Poll in a tight loop without a delay
  • Assume a fixed price per clip — it depends on resolution and billing unit
  • Hardcode private keys
  • Use ethers v5 syntax

Code Examples

Generate a Clip End to End

import { ethers } from 'ethers';
import { createZGComputeNetworkBroker } from '@0gfoundation/0g-compute-ts-sdk';
import * as fs from 'fs';
import 'dotenv/config';

interface VideoJob {
  id: string;
  status: string; // 'queued' | 'in_progress' | 'completed' | 'failed' | ...
  error?: { message?: string };
}

async function generateVideo(
  prompt: string,
  outputPath: string,
  opts: { seconds?: number; size?: string } = {},
): Promise<string> {
  const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
  const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
  const broker = await createZGComputeNetworkBroker(wallet);
  const providerAddress = process.env.PROVIDER_ADDRESS!;

  // Video is expensive — refuse to submit if the ledger is thin.
  const led = await broker.ledger.getLedger();
  console.log(`available: ${ethers.formatEther(led.availableBalance)} 0G`);

  const { endpoint, model } = await broker.inference.getServiceMetadata(providerAddress);
  const headers = await broker.inference.getRequestHeaders(providerAddress, prompt);

  // 1. Submit
  const submit = await fetch(`${endpoint}/videos`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...headers },
    body: JSON.stringify({
      model,
      prompt,
      seconds: opts.seconds ?? 5,
      size: opts.size ?? '720p',
    }),
  });
  if (!submit.ok) {
    throw new Error(`Video submit failed: HTTP ${submit.status} ${await submit.text()}`);
  }
  const job: VideoJob = await submit.json();
  console.log(`job ${job.id} submitted (status=${job.status})`);

  // 2. Poll. Generation takes minutes, so poll slowly with a hard timeout.
  const pollMs = 10_000;
  const timeoutMs = 15 * 60_000;
  const startedAt = Date.now();
  let current = job;

  while (current.status !== 'completed') {
    if (current.status === 'failed') {
      throw new Error(`Video job failed: ${current.error?.message ?? 'unknown error'}`);
    }
    if (Date.now() - startedAt > timeoutMs) {
      throw new Error(`Video job ${job.id} timed out after ${timeoutMs / 60_000} minutes`);
    }
    await new Promise((r) => setTimeout(r, pollMs));

    // Re-sign: headers are per-request
    const pollHeaders = await broker.inference.getRequestHeaders(providerAddress);
    const poll = await fetch(`${endpoint}/videos/${job.id}`, { headers: { ...pollHeaders } });
    if (!poll.ok) throw new Error(`Poll failed: HTTP ${poll.status}`);
    current = await poll.json();
    console.log(`  status=${current.status}`);
  }

  // 3. Download the MP4
  const dlHeaders = await broker.inference.getRequestHeaders(providerAddress);
  const content = await fetch(`${endpoint}/videos/${job.id}/content`, {
    headers: { ...dlHeaders },
  });
  if (!content.ok) throw new Error(`Download failed: HTTP ${content.status}`);

  const bytes = Buffer.from(await content.arrayBuffer());
  fs.writeFileSync(outputPath, bytes);
  console.log(`wrote ${bytes.length} bytes to ${outputPath}`);

  // NOTE: no processResponse() — it throws for `video-generation`.
  return outputPath;
}

Image-to-Video

Pass a reference image via input_reference. The models accept text and image input.

async function animateImage(prompt: string, referenceUrl: string, outputPath: string) {
  const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
  const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
  const broker = await createZGComputeNetworkBroker(wallet);
  const providerAddress = process.env.PROVIDER_ADDRESS!;

  const { endpoint, model } = await broker.inference.getServiceMetadata(providerAddress);
  const headers = await broker.inference.getRequestHeaders(providerAddress, prompt);

  const submit = await fetch(`${endpoint}/videos`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...headers },
    body: JSON.stringify({
      model,
      prompt,
      input_reference: referenceUrl,
      seconds: 5,
      size: '720p',
    }),
  });
  if (!submit.ok) throw new Error(`Submit failed: HTTP ${submit.status}`);
  return submit.json();
}

Estimate Cost Before Submitting

// See the Models section above for why `pricing` needs widening.
interface VideoPricingVariant {
  dimensions?: Record<string, string>;
  unit: 'video_token' | 'video_second';
  unit_price: string;
}
interface VideoPricing {
  video_unit?: 'video_token' | 'video_second';
  variants?: VideoPricingVariant[];
}

async function estimateCost(providerAddress: string, seconds: number, resolution: string) {
  const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
  const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
  const broker = await createZGComputeNetworkBroker(wallet);

  const { models } = await broker.inference.getProviderModels(providerAddress);
  const m = models[0];
  const pricing = m.pricing as VideoPricing | undefined;
  const variants = pricing?.variants ?? [];

  const variant = variants.find((v) => v.dimensions?.resolution === resolution);
  if (!variant) {
    console.log(
      `No variant for ${resolution}; known:`,
      variants.map((v) => v.dimensions?.resolution),
    );
    return null;
  }

  // 'video_second' bills per generated second; 'video_token' bills on the
  // vendor-reported token count, which you cannot know ahead of time.
  if (variant.unit === 'video_second') {
    const total = BigInt(variant.unit_price) * BigInt(seconds);
    console.log(`~${ethers.formatEther(total)} 0G for ${seconds}s at ${resolution}`);
    return total;
  }

  console.log(`${m.id} bills per ${variant.unit}; exact cost is known only after generation`);
  return null;
}

Anti-Patterns

// BAD: processResponse() for video — throws "Unknown service type"
await broker.inference.processResponse(providerAddress, chatID, '');

// BAD: expecting video bytes from the submit call
const submit = await fetch(`${endpoint}/videos`, { method: 'POST', ... });
fs.writeFileSync('out.mp4', Buffer.from(await submit.arrayBuffer())); // it's a JSON job

// BAD: tight polling loop — hammers the provider and can trip rate limits
while (job.status !== 'completed') {
  job = await (await fetch(`${endpoint}/videos/${job.id}`)).json();
}

// BAD: submitting a long 2K clip while developing (can cost tens of 0G)
body: JSON.stringify({ model, prompt, seconds: 15, size: '2K' });

Common Errors & Fixes

ErrorCauseFix
Unknown service typeprocessResponse() on a video serviceDo not call it for video-generation
Job status: failedPrompt rejected or vendor errorRead error.message; simplify the prompt
Poll never completesClip still renderingPoll slowly; allow many minutes, set timeout
HTTP 402 / insufficientSub-account cannot cover the clipTop up; video costs far more than chat
AccountNotExistsacknowledged() before sub-account existedUse checkProviderSignerStatus() first

Related Skills

  • Provider Discovery — find providers and read pricing variants
  • Account Management — funding (budget carefully here)
  • Text to Image — cheaper, synchronous stills
  • Compute + Storage — archive clips on 0G Storage

References

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.