Skip to main content

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 the moderation header. See Inline Moderation for supported video routes, inspectable image inputs, billing behavior, and error codes.

API Authentication

Supported authentication methods:
  1. API Key header: x-api-key: <your-api-key>
  2. Bearer token: Authorization: Bearer <your-api-key>
  3. 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 either imageDataUrl (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

Prefer videoUrl (camelCase) for source videos. Only send video if 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 via imageDataUrl or a public URL via imageUrl.

Seedance Models

Accepts base64 via imageDataUrl or a public URL via imageUrl. 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 through POST /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 (format vid_...)
  • id: Alias for runId (same value)
  • status: Always “pending” for initial response
  • model: The model used for generation
  • cost: Estimated/pre-charged cost
  • paymentSource: “USD” or “XNO”
  • remainingBalance: Account balance after deduction
  • prechargeLabel: Billing label for the precharge

Cost Information

Both the initial generation response and the status response include cost:
  • Initial response: estimated/pre-charged cost
  • Status response: final cost (when status is COMPLETED)
Pricing structures vary by model:
  • 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 a runId, poll the status endpoint until completion.

Status Endpoint

You can send requestId or runId; no model parameter is required.

Polling Example

Status Response States

In Progress

Completed

Failed

Status Values

  • IN_QUEUE: Request is queued
  • IN_PROGRESS: Video is being generated
  • COMPLETED: Video ready for download
  • FAILED: Generation failed
  • CANCELED: 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, or videoAttachmentId.
  • Session ownership is enforced; requests for jobs you do not own return 403.
  • Use POST /api/generate-video with 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 either imageDataUrl (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

Use the same polling loop from Example 1 to monitor either request.

Example 3: Image-to-Video with JavaScript

Using a public image URL directly

Example 4: Image-to-Video with Python

Reuse the polling helper from the JavaScript example (or your own status loop) to watch these run IDs until completion.

Example 5: Batch Processing

Error Handling

Error Response Format

Error Types: 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 resolution
  • hunyuan-video: Pro mode available
  • Various Kling models: Pro variants

Audio Generation

  • veo3-video: Set generateAudio: true to include audio

Reference-to-Video

Supported by kling-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

  1. Choose the Right Model
    • Use text-to-video for creative generation
    • Use image-to-video for animating existing content
    • Consider cost vs quality tradeoffs
  2. Optimize Prompts
    • Be specific and descriptive
    • Include motion and camera directions
    • Avoid content policy violations
  3. Handle Async Operations
    • Implement proper polling with delays
    • Set reasonable timeouts (5-10 minutes)
    • Show progress to users
  4. Error Recovery
    • Implement retry logic for transient failures
    • Handle rate limits with exponential backoff
    • Provide clear error messages to users
  5. Cost Management
    • Check balance before submitting
    • Estimate costs before generation
    • Use shorter durations for testing