Documentation

API Reference
POST

Video Generation

/v1/video/generations

Generate high-quality videos from text prompts using state-of-the-art models like Kling, Sora, and Veo. This endpoint provides a standardized interface for creating short video clips with customizable quality, aspect ratios, and duration.

Interactive Example

Request & Response Example

curl https://api.a4f.co/v1/video/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $A4F_API_KEY" \
-d '{
"model": "provider-2/kling-v2.1",
"prompt": "A cinematic drone shot of waves crashing against a cliff at sunset, 4k, photorealistic",
"quality": "1080p",
"duration": 5,
"ratio": "16:9"
}'

Authentication

Include your API key in the Authorization header.

Authorization: Bearer YOUR_API_KEY

Request Parameters

The API expects a JSON body with the following parameters.

model

string
Required
The ID of the model to use (e.g., provider-2/kling-v2.1). See Available Models below.

prompt

string
Required
A detailed text description of the desired video content. More descriptive prompts generally yield better results.

quality

string
Required
The resolution quality of the output. Supported values: 480p, 720p, 1080p. Note: 1080p is recommended for most models.

duration

integer
Required
The length of the video in seconds. Must be an integer between 1 and 8. Note: Specific models have specific maximum limits (see Model Capabilities below).

ratio

string
The aspect ratio of the generated video. Supported values: 1:1, 16:9, 9:16, 3:4, 4:3.

Default: 9:16

Response Format

The API returns a JSON object containing the generated video data.

created

integer
The Unix timestamp of when the video generation was completed.

data

array of objects
An array containing the generated video data.

b64_json

string
The base64-encoded video data (MP4 format). Decode this to save the video file.

url

string | null
Currently returns null. Reserved for future hosted URL support.

revised_prompt

string | null
Currently returns null. Reserved for future prompt revision support.

Available Models & Capabilities

Different models have different performance characteristics and limitations. Refer to this table to choose the right parameters.

Model IDProviderMax DurationSupported QualitiesRecommendation
provider-2/seedance-liteTencent5s1080p✓ Daily use
provider-2/kling-v2.1Kuaishou5s720p, 1080p✓ Daily use
provider-2/sora-2OpenAI4s720p, 1080pBalanced
provider-2/veo-fastGoogle8s720p, 1080pLonger videos
provider-2/seedance-proTencent5s1080pUse sparingly
provider-2/sora-2-proOpenAI5s720p, 1080pUse sparingly
provider-2/veoGoogle8s720p, 1080pUse sparingly

🏃 Longest Duration

Veo models support up to 8 seconds—the longest duration available.

💡 Recommended for Daily Use

Seedance Lite and Kling v2.1 offer great quality with efficient resource usage.

⭐ Premium Quality

Veo and Sora 2 Pro deliver the highest quality—use when truly needed.

Common Errors

Status CodeError CodeDescription
400invalid_request_errorValidation Error: Occurs if duration is not an integer, quality is missing, or parameters are out of allowed ranges.
400n_exceeds_model_limitThe requested duration or quality exceeds what the specific model supports.
401invalid_api_keyYour API key is missing or invalid.
403permission_denied_errorThe requested model is not available on your current subscription plan (Pro or Ultra required).
429rate_limit_exceededYou have exceeded your rate limits or daily quota.
500provider_errorThe upstream video generation service failed to produce the video. Please try again.

Was this page helpful?