AI Video APIAI Video API


HappyHorse 1.0

HappyHorse 1.0 is Alibaba's cinematic video generation model, exposing two modes: text-to-video and image-to-video.

Models

Model NameMode
happyhorse-1.0-text-to-videoText-to-video
happyhorse-1.0-image-to-videoImage-to-video

Pricing

Billed per second × resolution:

ResolutionCredits/sec
720p34
1080p67

Credits are pre-charged as duration × rate when the task is created. Failed tasks are automatically refunded.

Create Task

POST https://api.aivideoapi.ai/v1/videos/generations

Request Body

FieldTypeRequiredDescription
modelstringYeshappyhorse-1.0-text-to-video or happyhorse-1.0-image-to-video
inputobjectYesGeneration parameters, see below
callback_urlstringNoURL to receive task completion/failure notifications

Text-to-Video Input

FieldTypeRequiredDescription
promptstringYesText prompt, max 2500 characters
aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, or 3:4
resolutionstringNo720p or 1080p (default 720p)
durationintegerNo3-15 seconds (default 5)
seedintegerNoInteger between 0 and 2147483647

Image-to-Video Input

FieldTypeRequiredDescription
promptstringYesText prompt, max 2500 characters
image_urlsstring[]YesExactly 1 image URL, used as the first frame
resolutionstringNo720p or 1080p (default 720p)
durationintegerNo3-15 seconds (default 5)
seedintegerNoInteger between 0 and 2147483647

Image-to-video accepts a single HTTP(S) image URL only. Recommended formats: JPEG / PNG / BMP / WEBP. The source image should be at least 300px on the short side, under 10 MB, and roughly within a 1:2.5 to 2.5:1 aspect ratio.

Example: Text-to-Video

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "happyhorse-1.0-text-to-video",
    "input": {
      "prompt": "A cinematic tracking shot through a rainy neon street at night",
      "aspect_ratio": "16:9",
      "resolution": "720p",
      "duration": 5
    }
  }'

Example: Image-to-Video

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "happyhorse-1.0-image-to-video",
    "input": {
      "prompt": "The girl slowly turns her head and the camera gently pushes in",
      "image_urls": ["https://example.com/portrait.png"],
      "resolution": "1080p",
      "duration": 5,
      "seed": 12345
    }
  }'

Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24"
  }
}

Query Task

curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
  -H "Authorization: Bearer sk-your-api-key"

Status transitions: pending -> processing -> completed or failed.

Processing

{
  "id": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24",
  "status": "processing",
  "model": "happyhorse-1.0-text-to-video",
  "created_at": 1775400000,
  "progress": null
}

Completed

{
  "id": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24",
  "status": "completed",
  "model": "happyhorse-1.0-text-to-video",
  "created_at": 1775400000,
  "completed_at": 1775400123,
  "output": {
    "urls": [
      "https://file.aivideoapi.ai/videos/2026/04/29/happyhorse-example.mp4"
    ],
    "metadata": {
      "model": "alibaba/happyhorse-1.0/text-to-video",
      "has_nsfw_contents": false
    }
  }
}

Failed

{
  "id": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24",
  "status": "failed",
  "model": "happyhorse-1.0-text-to-video",
  "created_at": 1775400000,
  "error": {
    "code": "upstream_error",
    "message": "Video generation failed"
  }
}

When a task fails, pre-charged credits are automatically refunded.


Error Codes

When a request fails, the API returns a JSON error response:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

Error Reference

HTTP StatusCodeTypeDescription
400invalid_requestinvalid_request_errorMissing or invalid parameters
401invalid_api_keyauthentication_errorAPI key is invalid, disabled, or deleted
402insufficient_creditsbilling_errorCredit balance too low, please top up
403ip_not_allowedpermission_errorRequest IP not in the key's allowlist
404model_not_foundinvalid_request_errorModel does not exist or is inactive
404task_not_foundinvalid_request_errorTask ID does not exist
429rate_limit_exceededrate_limit_errorToo many requests, please slow down
429spend_limit_exceededbilling_errorKey spend limit reached (hourly/daily/total)
500internal_errorapi_errorUnexpected server error
503upstream_errorupstream_errorUpstream AI provider returned an error

Common Scenarios

invalid_request (400)

Returned when required fields are missing or invalid.

{
  "error": {
    "code": "invalid_request",
    "message": "'model' is required.",
    "type": "invalid_request_error"
  }
}

insufficient_credits (402)

Your balance is too low. Check your balance with GET /v1/credits and top up in Dashboard > Billing.

invalid_api_key (401)

Possible causes:

  • The key does not start with sk-
  • The key has been disabled or deleted
  • The user account has been banned

upstream_error (503)

The upstream AI provider returned an error. This may happen when:

  • The input contains sensitive or prohibited content
  • The provider is temporarily unavailable
  • The request parameters are not supported by the provider

Credits are automatically refunded when a task fails due to upstream errors.