Video Reverse Prompt API
API for analyzing videos to extract detailed shot breakdowns and prompts.
Try it online: https://nanophoto.ai/video-reverse-prompt
Endpoint
POST /api/sora-2/reverse-promptAuthentication
Authorization: Bearer YOUR_API_KEYCredits
1 credit per analysis (API calls only; web interface is free).
Request
Headers
| Header | Value |
|---|---|
Content-Type | application/json |
Authorization | Bearer YOUR_API_KEY |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoSource | string | Yes | Video source type: youtube, url, or file |
locale | string | No | Output language (default: en). Supported: en, zh, zh-TW, ja, ko, es, fr, de, pt, ru, ar |
videoUrl | string | Conditional | Video URL. YouTube link (when videoSource is youtube) or direct .mp4 URL (when videoSource is url) |
videoFile | string | Conditional | Base64-encoded video file (required when videoSource is file) |
videoFileName | string | No | Original filename for uploaded videos |
Examples
YouTube Video
curl -X POST "https://nanophoto.ai/api/sora-2/reverse-prompt" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-raw '{
"videoSource": "youtube",
"locale": "en",
"videoUrl": "https://www.youtube.com/watch?v=W-15-UmGP5s"
}'Video URL
curl -X POST "https://nanophoto.ai/api/sora-2/reverse-prompt" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-raw '{
"videoSource": "url",
"locale": "zh",
"videoUrl": "https://static.nanophoto.ai/demo/sk2-ad.mp4"
}'File Upload (Base64)
Read the video file and encode it to Base64, then pass it in the videoFile field.
import { readFile } from "node:fs/promises";
const videoBuffer = await readFile("your-video.mp4");
const videoBase64 = videoBuffer.toString("base64");
const response = await fetch("https://nanophoto.ai/api/sora-2/reverse-prompt", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
videoSource: "file",
locale: "en",
videoFile: videoBase64,
videoFileName: "your-video.mp4",
}),
});
// Streaming response
const reader = response.body!.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value));
}- Only
.mp4format is supported - Maximum file size: 30 MB (before Base64 encoding)
- The
videoFilevalue can be a plain Base64 string or a Data URL (e.g.data:video/mp4;base64,...)
Response
Success - Streaming
The API returns a streaming text response (Content-Type: text/plain; charset=utf-8). The AI analysis is streamed as it's generated, containing a detailed shot breakdown in Markdown table format.
The output includes:
- Shot number, framing/angle, camera movement
- Detailed visual description
- Audio analysis (BGM, sound effects, narration)
- Duration per shot
- Overall summary
Error
{
"success": false,
"error": "AI service temporarily unavailable. Please try again later.",
"errorCode": "AI_SERVICE_ERROR"
}Error Codes
| errorCode | HTTP Status | Description |
|---|---|---|
LOGIN_REQUIRED | 401 | Authentication required |
API_KEY_RATE_LIMIT_EXCEEDED | 429 | Rate limit exceeded |
INSUFFICIENT_CREDITS | 402 | Not enough credits |
INVALID_INPUT | 400 | Missing required parameters |
INVALID_YOUTUBE_URL | 400 | Invalid YouTube URL |
INVALID_VIDEO_URL | 400 | Invalid video URL |
INVALID_FORMAT | 400 | Invalid MP4 format |
FILE_TOO_LARGE | 400 | File exceeds 30MB |
VIDEO_DOWNLOAD_FAILED | 400 | Video download failed |
VIDEO_PROCESSING_FAILED | 422 | Video processing failed |
AI_SERVICE_ERROR | 503 | AI service unavailable |
SERVICE_UNAVAILABLE | 503 | Service configuration issue |
INTERNAL_ERROR | 500 | Internal server error |
NanoPhoto.AI Документация