Grok Image-to-Video
Transform static images into dynamic videos using xAI's Grok model with flexible duration control
Tool Overview
The Grok Image-to-Video tool uses xAI's Grok Imagine Video model to generate high-quality video content from a starting image and text description. It supports flexible video duration (3-15 seconds) and multiple aspect ratios, with cost scaling based on video length.
Tool Identifier
grok-image-to-video-api
Parameters
Required Parameters
prompt
- Type:
string(required) - Description: Text description of the desired motion and video content. Focus on describing the movement rather than the image contents
- Validation: Must be a non-empty string
- Example:
"The character turns around and smiles at the camera"
image
- Type:
string(required) - Description: Image URL for the video's starting frame
- Format: Must be a complete HTTP/HTTPS URL (e.g.,
https://cdn.sjinn.ai/uploads/image.jpg) - Validation: Must be a non-empty string
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
Landscape Video (16:9)
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-image-to-video-api",
"input": {
"prompt": "The character turns around and smiles at the camera",
"image": "https://cdn.sjinn.ai/uploads/character.jpg",
"duration": 5,
"aspect_ratio": "16:9"
}
}'
Portrait Video (9:16)
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-image-to-video-api",
"input": {
"prompt": "The model strikes a pose and walks forward confidently",
"image": "https://cdn.sjinn.ai/uploads/model-portrait.jpg",
"duration": 8,
"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-image-to-video-api',
input: {
prompt: 'The character turns around and smiles at the camera',
image: 'https://cdn.sjinn.ai/uploads/character.jpg',
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-image-to-video-api',
'input': {
'prompt': 'The character turns around and smiles at the camera',
'image': 'https://cdn.sjinn.ai/uploads/character.jpg',
'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": "image is required",
"error_code": 400
}
Best Practices
- Image Quality: Use high-quality, clear starting images for better video results
- Prompt Focus: Describe the desired motion and movement rather than the image contents. The model already sees the image
- Aspect Ratio Matching: The starting image aspect ratio should ideally match the
aspect_ratioparameter for best results - Duration Selection: Start with shorter durations (3-5s) for testing, then increase for final output
- 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
