Grok Text-to-Video
Generate high-quality videos from text descriptions using xAI's Grok model with flexible duration control
Tool Overview
The Grok Text-to-Video tool uses xAI's Grok Imagine Video model to generate high-quality video content from text descriptions. It supports flexible video duration (3-15 seconds) and multiple aspect ratios, with cost scaling based on video length.
Tool Identifier
grok-text-to-video-api
Parameters
Required Parameters
prompt
- Type:
string(required) - Description: Text description of the video content to guide AI video generation
- Validation: Must be a non-empty string
- Example:
"A cat playing piano in a jazz club, cinematic lighting"
Optional Parameters
duration
- Type:
number(optional) - Default:
5 - Range:
3-15(seconds) - Note: Values outside the valid range will default to
5. String values are automatically parsed to numbers
aspect_ratio
- Type:
string(optional) - Default:
"16:9" - Supported Values:
"16:9"- Landscape format, suitable for YouTube, TV, and other platforms"9:16"- Portrait format, suitable for TikTok, Instagram Story, and other platforms"1:1"- Square format, suitable for Instagram posts
- Note: If an invalid value is provided, it will automatically default to
"16:9"
Pricing
- Credits Consumed: 50 credits per second (duration × 50)
- Examples: 5s video = 250 credits, 10s video = 500 credits, 15s video = 750 credits
- Membership Requirement: None
Request Examples
Short Video (5 seconds)
curl -X POST https://sjinn.ai/api/un-api/create_tool_task \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tool_type": "grok-text-to-video-api",
"input": {
"prompt": "A cat playing piano in a jazz club, cinematic lighting",
"duration": 5,
"aspect_ratio": "16:9"
}
}'
Long Video (15 seconds, Portrait)
curl -X POST https://sjinn.ai/api/un-api/create_tool_task \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tool_type": "grok-text-to-video-api",
"input": {
"prompt": "A fashion model walking down a runway with dramatic lighting effects",
"duration": 15,
"aspect_ratio": "9:16"
}
}'
Using JavaScript
const response = await fetch('https://sjinn.ai/api/un-api/create_tool_task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
tool_type: 'grok-text-to-video-api',
input: {
prompt: 'A cat playing piano in a jazz club, cinematic lighting',
duration: 5,
aspect_ratio: '16:9',
},
}),
});
const result = await response.json();
console.log('Task ID:', result.data.task_id);
Using Python
import requests
url = 'https://sjinn.ai/api/un-api/create_tool_task'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
data = {
'tool_type': 'grok-text-to-video-api',
'input': {
'prompt': 'A cat playing piano in a jazz club, cinematic lighting',
'duration': 5,
'aspect_ratio': '16:9'
}
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print('Task ID:', result['data']['task_id'])
Response Examples
Success Response
{
"success": true,
"errorMsg": "",
"error_code": 0,
"data": {
"task_id": "550e8400-e29b-41d4-a716-446655440000"
}
}
Error Response
{
"success": false,
"errorMsg": "Insufficient balance",
"error_code": 100
}
Best Practices
- Duration Selection: Start with shorter durations (3-5s) for testing, then increase for final output. Cost scales linearly with duration
- Prompt Optimization: Use detailed, specific descriptions including camera movement, lighting, and style details
- Aspect Ratio Selection:
- Use
16:9for landscape platforms like YouTube, Bilibili, and TV - Use
9:16for portrait platforms like TikTok, Instagram Story, and Kuaishou - Use
1:1for square formats like Instagram posts
- Use
- Cost Awareness: A 15-second video costs 3x more than a 5-second video. Plan accordingly
- Generation Time: Video generation typically takes 2-8 minutes depending on duration
