Overview
The NanoGPT API provides advanced video generation capabilities using state-of-the-art models. This guide covers how to use our video generation endpoints. For authenticated API-key requests, you can opt in to a paid input safety preflight by sending themoderation header. See Inline Moderation for supported video routes, inspectable image inputs, billing behavior, and error codes.
API Authentication
Supported authentication methods:- API Key header:
x-api-key: <your-api-key> - Bearer token:
Authorization: Bearer <your-api-key> - Cookie session: for web clients (automatic)
Header Examples
Making a Video Generation Request
Endpoint
Request Headers
Request Body
Basic Text-to-Video Request
Image-to-Video Request
Image-conditioned models accept eitherimageDataUrl (base64) or imageUrl (a public HTTPS link). The platform always uses the explicit field you send before falling back to any library attachments.
Uploads sent via the API must be 4 MB or smaller. For larger assets, host them externally and provide an imageUrl.
Base64 input
Public URL input
Additional Request Parameters
These parameters are available across models. Only send the fields your chosen model supports.Core Parameters
PrefervideoUrl(camelCase) for source videos. Only sendvideoif the model explicitly requires it.
Audio Parameters (lipsync/avatar models)
Model-Specific Parameters
Model-Specific Parameters
Veo Models
Kling Models
Hunyuan Models
Wan Image-to-Video
Accepts base64 viaimageDataUrlor a public URL viaimageUrl.
Seedance Models
Accepts base64 viaimageDataUrlor a public URL viaimageUrl. Ensure URLs are directly fetchable.
Supported Models
Text-to-Video Models
Image-to-Video Only Models
Avatar/Lipsync Models
Utility Models
Extension Models
Extend models run throughPOST /api/generate-video with prompt plus a source video input (videoUrl, videoDataUrl, or videoAttachmentId). The task-based /api/generate-video/extend endpoint is only for Midjourney extensions.
Max source video length: 120 seconds.
Longstories Models (Scripted Video)
Response Format
Initial Response (202 Accepted)
Response Fields
runId: NanoGPT job ID used for polling (formatvid_...)id: Alias forrunId(same value)status: Always “pending” for initial responsemodel: The model used for generationcost: Estimated/pre-charged costpaymentSource: “USD” or “XNO”remainingBalance: Account balance after deductionprechargeLabel: Billing label for the precharge
Cost Information
Both the initial generation response and the status response includecost:
- Initial response: estimated/pre-charged cost
- Status response: final cost (when
statusisCOMPLETED)
- Fixed: flat rate per generation
- Per-Second: rate x duration
- Resolution-Based: rates per resolution tier
- Duration-Based: step pricing (5s vs 10s)
- Mode-Based: different rates for T2V vs I2V
Polling for Status
After receiving arunId, poll the status endpoint until completion.
Status Endpoint
requestId or runId; no model parameter is required.
Polling Example
Status Response States
In Progress
Completed
Failed
Status Values
IN_QUEUE: Request is queuedIN_PROGRESS: Video is being generatedCOMPLETED: Video ready for downloadFAILED: Generation failedCANCELED: Request was canceled
Additional Endpoints
GET /api/generate-video/recover
Recover recent video generation runs for a user.
Query Parameters
Rate Limit: 20 requests/minute
POST /api/generate-video/extend
Extend a Midjourney video using a task-based flow.
Rate Limit: 20 requests/minute
Required Fields: runId (preferred) or taskId (legacy alias), index (0-3)
Notes:
- This endpoint does not accept
video,videoUrl,videoDataUrl, orvideoAttachmentId. - Session ownership is enforced; requests for jobs you do not own return
403. - Use
POST /api/generate-videowith an extend model for source-video extension.
GET /api/generate-video/content
Proxy content retrieval for Sora 2 videos.
Query Parameters
Complete Examples
The submit + poll flow works the same regardless of how you supply the image: image-conditioned models accept eitherimageDataUrl (base64) or a public imageUrl, and the platform prefers whichever field you send before checking library attachments.
Example 1: Text-to-Video with cURL
Example 2: Image-to-Video with cURL
Base64 input
Public URL input
Example 3: Image-to-Video with JavaScript
Using a public image URL directly
Example 4: Image-to-Video with Python
Example 5: Batch Processing
Error Handling
Error Response Format
CONTENT_POLICY_VIOLATION, PRO_REQUIRED, INSUFFICIENT_BALANCE, RATE_LIMITED
Error Handling Best Practices
Rate Limits
Additional Notes
Pro Mode
sora-2: Pro mode required for 1792x1024 resolutionhunyuan-video: Pro mode available- Various Kling models: Pro variants
Audio Generation
veo3-video: SetgenerateAudio: trueto include audio
Reference-to-Video
Supported bykling-video-o1, kling-video-o1-standard, wan-wavespeed-26.
Use referenceImages with image URLs or data URLs.
Automatic Refunds
Refunds are automatically issued when:- The job returns a failure
- Content policy violation (before processing)
- Submission fails before acknowledgement
Best Practices
-
Choose the Right Model
- Use text-to-video for creative generation
- Use image-to-video for animating existing content
- Consider cost vs quality tradeoffs
-
Optimize Prompts
- Be specific and descriptive
- Include motion and camera directions
- Avoid content policy violations
-
Handle Async Operations
- Implement proper polling with delays
- Set reasonable timeouts (5-10 minutes)
- Show progress to users
-
Error Recovery
- Implement retry logic for transient failures
- Handle rate limits with exponential backoff
- Provide clear error messages to users
-
Cost Management
- Check balance before submitting
- Estimate costs before generation
- Use shorter durations for testing