Generate AI videos using USDC payments via the x402 protocol.
https://payment.unreel.ai/api/generate-x402Generate video (requires payment)/api/jobs/{job_id}Get job status (no auth)The simplest way to integrate. Uses standard x402 v2 protocol with CDP facilitator. Payment is handled automatically by the @x402/fetch library.
npm install @x402/fetch @x402/evm viemimport { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
// Create signer from private key
const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
// Create x402 client and register EVM scheme
const client = new x402Client();
registerExactEvmScheme(client, { signer });
// Wrap fetch with automatic payment handling
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
// Make request - payment is handled automatically!
const response = await fetchWithPayment(
"https://payment.unreel.ai/api/generate-x402",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
script_text: "A cat walking on a rainbow bridge in space",
}),
}
);
const { job_id, status_url } = await response.json();
console.log("Job created:", job_id);
// Poll for completion
const pollForResult = async (url: string) => {
while (true) {
const res = await fetch(url);
const job = await res.json();
if (job.status === "completed") return job.video_url;
if (job.status === "failed") throw new Error(job.error);
await new Promise(r => setTimeout(r, 10000));
}
};
const videoUrl = await pollForResult(status_url);
console.log("Video ready:", videoUrl);Use our MCP server to let AI agents generate videos with automatic payment handling.
{
"mcpServers": {
"unreel-video": {
"command": "npx",
"args": ["tsx", "/path/to/unreel-mcp/index.ts"],
"env": {
"EVM_PRIVATE_KEY": "0x_your_base_private_key"
}
}
}
}{
"x402Version": 2,
"accepts": [{
"scheme": "exact",
"network": "eip155:8453",
"amount": "25000000",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0xf50ccDFEf8E0816757e8E491ad70D1CfD2261a50",
"maxTimeoutSeconds": 300
}],
"resource": {
"url": "https://payment.unreel.ai/api/generate-x402",
"description": "Generate AI video from natural language script"
}
}Provide a webhook_url to receive callbacks on completion.
{
"job_id": "81df8504-0860-41e2-aaf9-92c321f11532",
"status": "completed",
"result": {
"video_url": "https://payment.unreel.ai/videos/.../final.mp4",
"duration": 10.5
}
}| Name | Value |
|---|---|
| API Endpoint | https://payment.unreel.ai |
| USDC Contract | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| Platform Wallet | 0xf50ccDFEf8E0816757e8E491ad70D1CfD2261a50 |
| Facilitator | https://api.cdp.coinbase.com/platform/v2/x402 |
| Network (CAIP-2) | eip155:8453 |
| Chain ID | 8453 |