Video Reverse Prompt
Analyze videos to extract detailed shot breakdowns and AI-ready prompts via the NanoPhoto.AI API.
Use the bundled script for local file uploads instead of inlining large base64 payloads directly in the shell; it is more reliable for multi-megabyte videos.
Prerequisites
- 1. Obtain an API key at: https://nanophoto.ai/settings/apikeys
- Configure
NANOPHOTO_API_KEY before using the skill.
Preferred OpenClaw setup:
- - Open the skill settings for this skill
- Add an environment variable named INLINECODE1
- Paste the API key as its value
Equivalent config shape:
CODEBLOCK0
Other valid ways to provide the key:
- - Shell: INLINECODE2
- Tool-specific env config: any runtime that injects INLINECODE3
Credential declaration summary:
- - Required env var: INLINECODE4
- Primary credential: INLINECODE5
- No unrelated credentials are required
If the env var is not set, ask the user to configure it before proceeding.
Workflow
- 1. Collect the video source from the user (YouTube link, direct .mp4 URL, or local file path)
- Determine
videoSource type: youtube, url, or INLINECODE9 - Confirm the user is authorized to upload or process the content
- If local file: read and base64-encode it (must be .mp4, max 30 MB)
- Call the API (streaming response)
- Return the shot breakdown and prompts to the user
API Call
YouTube Video
CODEBLOCK1
Direct Video URL
CODEBLOCK2
Local File (Preferred: bundled script)
CODEBLOCK3
The script reads NANOPHOTO_API_KEY from the environment, validates the file size/format, base64-encodes the MP4, and prints the streaming text response.
Local File (Manual Base64 request)
CODEBLOCK4
Parameters
| Parameter | Type | Required | Description |
|---|
| INLINECODE11 | string | Yes | INLINECODE12 , url, or INLINECODE14 |
| INLINECODE15 |
string | No | Output language (default:
en). Supported:
en,
zh,
zh-TW,
ja,
ko,
es,
fr,
de,
pt,
ru,
ar |
|
videoUrl | string | Conditional | YouTube link or direct .mp4 URL |
|
videoFile | string | Conditional | Base64-encoded video (when
videoSource is
file) |
|
videoFileName | string | No | Original filename for uploaded videos |
Constraints
- - Only
.mp4 format supported - Max file size: 30 MB (before base64 encoding)
- INLINECODE34 accepts plain base64 or Data URL (
data:video/mp4;base64,...) - Costs 1 credit per API call
Response
The API returns a streaming text response (Content-Type: text/plain; charset=utf-8) containing a Markdown table with:
- - Shot number, framing/angle, camera movement
- Detailed visual description
- Audio analysis (BGM, sound effects, narration)
- Duration per shot
- Overall summary
Error Handling
| errorCode | HTTP | Cause | Action |
|---|
| INLINECODE37 | 401 | Invalid or missing API key | Verify key at https://nanophoto.ai/settings/apikeys |
| INLINECODE38 |
429 | Rate limit exceeded | Wait and retry |
|
INSUFFICIENT_CREDITS | 402 | Not enough credits | Top up credits |
|
INVALID_INPUT | 400 | Missing required parameters | Check
videoSource and corresponding fields |
|
INVALID_YOUTUBE_URL | 400 | Invalid YouTube URL | Ask user for a valid YouTube link |
|
INVALID_VIDEO_URL | 400 | Invalid video URL | Ask user for a valid .mp4 URL |
|
INVALID_FORMAT | 400 | Not MP4 format | Only .mp4 is supported |
|
FILE_TOO_LARGE | 400 | File exceeds 30 MB | Ask user for a smaller file |
|
VIDEO_DOWNLOAD_FAILED | 400 | Cannot download video | Check URL accessibility |
|
VIDEO_PROCESSING_FAILED | 422 | Processing error | Retry or try a different video |
|
AI_SERVICE_ERROR | 503 | AI service unavailable | Retry later |
Bundled script
- -
scripts/reverse_prompt_file.py: Reliable local-file uploader for .mp4 inputs. Use it when the user provides a local video path.
Full API Reference
See references/api.md for complete endpoint documentation.
视频反向提示
通过NanoPhoto.AI API分析视频,提取详细镜头分解和AI就绪提示。
使用捆绑脚本进行本地文件上传,而不是直接在shell中内联大型base64负载;对于数兆字节的视频,这种方式更可靠。
前置条件
- 1. 在以下地址获取API密钥:https://nanophoto.ai/settings/apikeys
- 使用技能前配置NANOPHOTOAPIKEY。
推荐的OpenClaw设置:
- - 打开此技能的技能设置
- 添加名为NANOPHOTOAPIKEY的环境变量
- 将API密钥粘贴为其值
等效配置格式:
json
{
skills: {
entries: {
video-reverse-prompt: {
enabled: true,
env: {
NANOPHOTOAPIKEY: yourapikey_here
}
}
}
}
}
提供密钥的其他有效方式:
- - Shell:export NANOPHOTOAPIKEY=yourapikeyhere
- 工具特定环境配置:任何注入NANOPHOTOAPI_KEY的运行时
凭据声明摘要:
- - 必需的环境变量:NANOPHOTOAPIKEY
- 主要凭据:NANOPHOTOAPIKEY
- 不需要无关凭据
如果未设置环境变量,请要求用户先进行配置。
工作流程
- 1. 从用户处收集视频源(YouTube链接、直接.mp4 URL或本地文件路径)
- 确定videoSource类型:youtube、url或file
- 确认用户有权上传或处理内容
- 如果是本地文件:读取并进行base64编码(必须为.mp4格式,最大30 MB)
- 调用API(流式响应)
- 向用户返回镜头分解和提示
API调用
YouTube视频
bash
curl -X POST https://nanophoto.ai/api/sora-2/reverse-prompt \
-H Content-Type: application/json \
-H Authorization: Bearer $NANOPHOTOAPIKEY \
--data-raw {
videoSource: youtube,
locale: en,
videoUrl: https://www.youtube.com/watch?v=XXXXXXXXXXX
}
直接视频URL
bash
curl -X POST https://nanophoto.ai/api/sora-2/reverse-prompt \
-H Content-Type: application/json \
-H Authorization: Bearer $NANOPHOTOAPIKEY \
--data-raw {
videoSource: url,
locale: en,
videoUrl: https://example.com/video.mp4
}
本地文件(推荐:捆绑脚本)
bash
python3 scripts/reversepromptfile.py your-video.mp4 --locale en
该脚本从环境变量读取NANOPHOTOAPIKEY,验证文件大小/格式,对MP4进行base64编码,并打印流式文本响应。
本地文件(手动Base64请求)
bash
VIDEO_BASE64=$(base64 < your-video.mp4)
curl -X POST https://nanophoto.ai/api/sora-2/reverse-prompt \
-H Content-Type: application/json \
-H Authorization: Bearer $NANOPHOTOAPIKEY \
--data-raw {
\videoSource\: \file\,
\locale\: \en\,
\videoFile\: \$VIDEO_BASE64\,
\videoFileName\: \your-video.mp4\
}
参数
| 参数 | 类型 | 必需 | 描述 |
|---|
| videoSource | 字符串 | 是 | youtube、url或file |
| locale |
字符串 | 否 | 输出语言(默认:en)。支持:en、zh、zh-TW、ja、ko、es、fr、de、pt、ru、ar |
| videoUrl | 字符串 | 条件性 | YouTube链接或直接.mp4 URL |
| videoFile | 字符串 | 条件性 | Base64编码的视频(当videoSource为file时) |
| videoFileName | 字符串 | 否 | 上传视频的原始文件名 |
限制
- - 仅支持.mp4格式
- 最大文件大小:30 MB(base64编码前)
- videoFile接受纯base64或数据URL(data:video/mp4;base64,...)
- 每次API调用消耗1个积分
响应
API返回流式文本响应(Content-Type: text/plain; charset=utf-8),包含Markdown表格:
- - 镜头编号、构图/角度、摄像机运动
- 详细视觉描述
- 音频分析(背景音乐、音效、旁白)
- 每个镜头的时长
- 整体摘要
错误处理
| errorCode | HTTP | 原因 | 操作 |
|---|
| LOGINREQUIRED | 401 | API密钥无效或缺失 | 在https://nanophoto.ai/settings/apikeys验证密钥 |
| APIKEYRATELIMIT_EXCEEDED |
429 | 超出速率限制 | 等待后重试 |
| INSUFFICIENT_CREDITS | 402 | 积分不足 | 充值积分 |
| INVALID_INPUT | 400 | 缺少必需参数 | 检查videoSource和对应字段 |
| INVALID
YOUTUBEURL | 400 | YouTube URL无效 | 要求用户提供有效的YouTube链接 |
| INVALID
VIDEOURL | 400 | 视频URL无效 | 要求用户提供有效的.mp4 URL |
| INVALID_FORMAT | 400 | 非MP4格式 | 仅支持.mp4格式 |
| FILE
TOOLARGE | 400 | 文件超过30 MB | 要求用户提供较小的文件 |
| VIDEO
DOWNLOADFAILED | 400 | 无法下载视频 | 检查URL可访问性 |
| VIDEO
PROCESSINGFAILED | 422 | 处理错误 | 重试或尝试其他视频 |
| AI
SERVICEERROR | 503 | AI服务不可用 | 稍后重试 |
捆绑脚本
- - scripts/reversepromptfile.py:用于.mp4输入的可靠本地文件上传器。当用户提供本地视频路径时使用。
完整API参考
完整端点文档请参见references/api.md。