Sora 2 Prompt Generator API
API for generating professional Sora 2 video prompts from topics, with support for multiple video techniques and languages.
Try it online: https://nanophoto.ai/sora-2-prompt-generator
Endpoint
POST /api/sora-2/generate-promptAuthentication
Authorization: Bearer YOUR_API_KEYCredits
2 credits per generation.
Credits are pre-deducted when the request starts and automatically refunded if generation fails.
Request
Headers
| Header | Value |
|---|---|
Content-Type | application/json |
Authorization | Bearer YOUR_API_KEY |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
topic | string | Yes | Video topic or scene description (max 500 characters) |
mode | string | No | textToVideo or imageToVideo (default: textToVideo) |
technique | string | No | Video technique (see below). Default: montage |
duration | number | No | Video duration in seconds (default: 10) |
model | string | No | AI model (default: google/gemini-3-flash-preview) |
locale | string | No | Output language (default: en). Supported: en, zh, zh-TW, ja, ko, es, fr, de, pt, ru, ar |
imageUrls | string[] | No | Public image URLs for imageToVideo mode (max 3) |
Supported Techniques
| Value | Description |
|---|---|
montage | Montage - rapid shot combination |
long-take | Long Take - single continuous shot |
time-lapse | Time-lapse photography |
slow-motion | Slow motion |
tracking-shot | Tracking shot |
aerial-view | Aerial view |
pov | POV / First person |
split-screen | Split screen |
match-cut | Match cut |
fade-transition | Fade transition |
imageUrlsonly accepts publicly accessible URLs. Base64 image upload is not supported via API.topicis limited to 500 characters maximum.
Examples
Text to Video Prompt
curl -X POST "https://nanophoto.ai/api/sora-2/generate-prompt" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-raw '{
"topic": "A serene Japanese garden with cherry blossoms falling into a koi pond",
"technique": "slow-motion",
"duration": 15,
"locale": "en"
}'Image to Video Prompt
curl -X POST "https://nanophoto.ai/api/sora-2/generate-prompt" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-raw '{
"topic": "Animate this landscape with gentle wind and floating clouds",
"mode": "imageToVideo",
"technique": "long-take",
"duration": 10,
"locale": "en",
"imageUrls": ["https://example.com/landscape.jpg"]
}'Response
Success - Streaming
The API returns a streaming text response (Content-Type: text/plain; charset=utf-8). The generated Sora 2 prompt is streamed as it's produced.
The output includes:
- Structured video prompt with timing markers
- Shot-by-shot breakdown
- Camera angles, movements, and lighting details
- Atmosphere and mood descriptions
Error
{
"success": false,
"error": "Insufficient credits. Required: 2 credits for prompt generation.",
"errorCode": "INSUFFICIENT_CREDITS",
"requiredCredits": 2
}Complete TypeScript Example
async function generatePrompt(apiKey: string) {
const response = await fetch("https://nanophoto.ai/api/sora-2/generate-prompt", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({
topic: "A futuristic cityscape at sunset with flying vehicles and neon lights",
technique: "aerial-view",
duration: 15,
locale: "en",
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(`Failed: ${error.error}`);
}
// Read streaming response
const reader = response.body!.getReader();
const decoder = new TextDecoder();
let prompt = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
prompt += chunk;
process.stdout.write(chunk);
}
console.log("\n\nFull prompt:", prompt);
return prompt;
}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 | Topic is missing, empty, or too long |
Documentação NanoPhoto.AI