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.API Authentication
1. API Key Authentication
Making a Video Generation Request
Endpoint
Request Headers
Request Body
Basic Text-to-Video Request
Image-to-Video Request
Model-Specific Parameters
Veo Models
Kling Models
Hunyuan Models
Wan Image-to-Video
Seedance Models
Response Format
Initial Response (202 Accepted)
Response Fields
runId
: Unique identifier for polling statusstatus
: Always “pending” for initial responsemodel
: The model used for generationcost
: Cost in USD or XNOpaymentSource
: “USD” or “XNO”remainingBalance
: Account balance after deduction
Polling for Status
After receiving arunId
, poll the status endpoint until completion.
Status Endpoint
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 failedCANCELLED
: Request was cancelled
Complete Examples
Example 1: Text-to-Video with cURL
Example 2: Image-to-Video with JavaScript
Example 3: Batch Processing
Error Handling
Common Error Responses
Insufficient Balance
Invalid Session
Rate Limit Exceeded
Content Policy Violation
Model-Specific Errors
Error Handling Best Practices
Rate Limits
- Default: 50 requests per minute per IP address
- API Key: Same as default
- Internal Auth: No rate limit
/api/generate-video
). Status polling endpoints have no rate limits.
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