
صورة إلى فيديو
Grok Imagine Video Image-to-Video API by xAI
xai/grok-imagine-video/image-to-video
Image-to-video
xAI Grok Imagine Video animates a starting frame image with natural-language motion prompts at 480p or 720p.

xAI Grok Imagine Video animates a starting frame image with natural-language motion prompts at 480p or 720p.
Join the Discord community for the latest model updates, prompts, and support.
كل مرة ستكلف $0.05 مع $10 يمكنك التشغيل حوالي 200 مرة
يمكنك المتابعة بـ:
import requests
import time
# Step 1: Start video generation
generate_url = "https://api.atlascloud.ai/api/v1/model/generateVideo"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer $ATLASCLOUD_API_KEY"
}
data = {
"model": "xai/grok-imagine-video/image-to-video", # Required. Model name
"prompt": "A beautiful sunset over the ocean with gentle waves", # Required. Natural-language motion prompt
"image_url": "example_value", # Required. Public HTTPS URL or base64 data URI of the starting-frame image (JPEG, PNG, or WebP)
"duration": 8, # Length of generated video in seconds. (min: 1, max: 15)
"resolution": "720p", # Output resolution. options: 480p | 720p
"aspect_ratio": "16:9", # Output aspect ratio
}
generate_response = requests.post(generate_url, headers=headers, json=data)
generate_result = generate_response.json()
prediction_id = generate_result["data"]["id"]
# Step 2: Poll for result
poll_url = f"https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}"
def check_status():
while True:
response = requests.get(poll_url, headers={"Authorization": "Bearer $ATLASCLOUD_API_KEY"})
result = response.json()
if result["data"]["status"] in ["completed", "succeeded"]:
print("Generated video:", result["data"]["outputs"][0])
return result["data"]["outputs"][0]
elif result["data"]["status"] == "failed":
raise Exception(result["data"]["error"] or "Generation failed")
else:
# Still processing, wait 2 seconds
time.sleep(2)
video_url = check_status()قم بتثبيت الحزمة المطلوبة للغة البرمجة الخاصة بك.
pip install requestsتتطلب جميع طلبات API المصادقة عبر مفتاح API. يمكنك الحصول على مفتاح API الخاص بك من لوحة تحكم Atlas Cloud.
export ATLASCLOUD_API_KEY="your-api-key-here"import os
API_KEY = os.environ.get("ATLASCLOUD_API_KEY")
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {API_KEY}"
}لا تكشف أبدًا مفتاح API الخاص بك في الكود من جانب العميل أو المستودعات العامة. استخدم متغيرات البيئة أو وكيل الخادم الخلفي بدلاً من ذلك.
import requests
url = "https://api.atlascloud.ai/api/v1/model/generateVideo"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer $ATLASCLOUD_API_KEY"
}
data = {
"model": "your-model",
"prompt": "A beautiful landscape"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())أرسل طلب توليد غير متزامن. تُرجع API معرّف التنبؤ الذي يمكنك استخدامه للتحقق من الحالة واسترداد النتيجة.
/api/v1/model/generateVideoimport requests
url = "https://api.atlascloud.ai/api/v1/model/generateVideo"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer $ATLASCLOUD_API_KEY"
}
data = {
"model": "xai/grok-imagine-video/image-to-video",
"prompt": "A beautiful sunset over the ocean with gentle waves"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(f"Prediction ID: {result['data']['id']}")
print(f"Status: {result['data']['status']}"){
"code": 200,
"data": {
"id": "pred_abc123",
"status": "processing",
"model": "model-name",
"created_at": "2025-01-01T00:00:00Z"
}
}استعلم عن نقطة نهاية التنبؤ للتحقق من الحالة الحالية لطلبك.
/api/v1/model/prediction/{prediction_id}import requests
import time
prediction_id = "pred_abc123"
url = f"https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}"
headers = { "Authorization": "Bearer $ATLASCLOUD_API_KEY" }
while True:
response = requests.get(url, headers=headers)
result = response.json()
status = result["data"]["status"]
print(f"Status: {status}")
if status in ["completed", "succeeded"]:
output_url = result["data"]["outputs"][0]
print(f"Output URL: {output_url}")
break
elif status == "failed":
print(f"Error: {result['data'].get('error', 'Unknown')}")
break
time.sleep(3)processingلا يزال الطلب قيد المعالجة.completedاكتمل التوليد. المخرجات متاحة.succeededنجح التوليد. المخرجات متاحة.failedفشل التوليد. تحقق من حقل الخطأ.{
"data": {
"id": "pred_abc123",
"status": "completed",
"outputs": [
"https://storage.atlascloud.ai/outputs/result.mp4"
],
"metrics": {
"predict_time": 45.2
},
"created_at": "2025-01-01T00:00:00Z",
"completed_at": "2025-01-01T00:00:10Z"
}
}ارفع الملفات إلى تخزين Atlas Cloud واحصل على URL يمكنك استخدامه في طلبات API الخاصة بك. استخدم multipart/form-data للرفع.
/api/v1/model/uploadMediaimport requests
url = "https://api.atlascloud.ai/api/v1/model/uploadMedia"
headers = { "Authorization": "Bearer $ATLASCLOUD_API_KEY" }
with open("image.png", "rb") as f:
files = {"file": ("image.png", f, "image/png")}
response = requests.post(url, headers=headers, files=files)
result = response.json()
download_url = result["data"]["download_url"]
print(f"File URL: {download_url}"){
"data": {
"download_url": "https://storage.atlascloud.ai/uploads/abc123/image.png",
"file_name": "image.png",
"content_type": "image/png",
"size": 1024000
}
}المعاملات التالية مقبولة في نص الطلب.
{
"model": "xai/grok-imagine-video/image-to-video",
"prompt": "A beautiful landscape",
"image_url": "example_image_url",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}تُرجع API استجابة تنبؤ تحتوي على عناوين URL للمخرجات المولّدة.
{
"id": "pred_abc123",
"status": "completed",
"model": "model-name",
"outputs": [
"https://storage.atlascloud.ai/outputs/result.mp4"
],
"metrics": {
"predict_time": 45.2
},
"created_at": "2025-01-01T00:00:00Z",
"completed_at": "2025-01-01T00:00:10Z"
}يدمج Atlas Cloud Skills أكثر من 400 نموذج ذكاء اصطناعي مباشرة في مساعد البرمجة بالذكاء الاصطناعي الخاص بك. أمر واحد للتثبيت، ثم استخدم اللغة الطبيعية لتوليد الصور ومقاطع الفيديو والدردشة مع LLM.
npx skills add AtlasCloudAI/atlas-cloud-skillsاحصل على مفتاح API الخاص بك من لوحة تحكم Atlas Cloud وعيّنه كمتغير بيئة.
export ATLASCLOUD_API_KEY="your-api-key-here"بمجرد التثبيت، يمكنك استخدام اللغة الطبيعية في مساعد الذكاء الاصطناعي الخاص بك للوصول إلى جميع نماذج Atlas Cloud.
يربط Atlas Cloud MCP Server بيئة التطوير الخاصة بك بأكثر من 400 نموذج ذكاء اصطناعي عبر Model Context Protocol. يعمل مع أي عميل متوافق مع MCP.
npx -y atlascloud-mcpأضف التكوين التالي إلى ملف إعدادات MCP في بيئة التطوير الخاصة بك.
{
"mcpServers": {
"atlascloud": {
"command": "npx",
"args": [
"-y",
"atlascloud-mcp"
],
"env": {
"ATLASCLOUD_API_KEY": "your-api-key-here"
}
}
}
}{
"info": {
"title": "AtlasCloud API",
"version": "1.0.0",
"description": "The AtlasCloud API."
},
"paths": {
"/api/v1/model/generateVideo": {
"post": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PredictionResponse"
}
}
},
"description": "The request status."
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Input"
}
}
},
"required": true
}
},
"x-api-name": "model_run"
},
"/api/v1/model/prediction/{request_id}": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PredictionResponse"
}
}
},
"description": "Result of the request."
}
},
"parameters": [
{
"in": "path",
"name": "request_id",
"schema": {
"type": "string",
"description": "Request ID"
},
"required": true
}
]
},
"x-api-name": "model_result"
}
},
"openapi": "3.0.0",
"servers": [
{
"url": "https://api.atlascloud.ai"
}
],
"components": {
"schemas": {
"Input": {
"type": "object",
"required": [
"model",
"prompt",
"image_url"
],
"properties": {
"model": {
"type": "string",
"description": "Model name.",
"default": "xai/grok-imagine-video/image-to-video"
},
"prompt": {
"type": "string",
"description": "Natural-language motion prompt. The starting frame is taken from the image."
},
"image_url": {
"type": "string",
"description": "Public HTTPS URL or base64 data URI of the starting-frame image (JPEG, PNG, or WebP)."
},
"duration": {
"type": "integer",
"default": 8,
"minimum": 1,
"maximum": 15,
"description": "Length of generated video in seconds. Range: 1–15."
},
"resolution": {
"type": "string",
"default": "720p",
"enum": [
"480p",
"720p"
],
"description": "Output resolution."
},
"aspect_ratio": {
"type": "string",
"default": "16:9",
"enum": [
"1:1",
"16:9",
"9:16",
"4:3",
"3:4",
"3:2",
"2:3"
],
"description": "Output aspect ratio. The default matches the input image; specifying a different value stretches the image."
}
},
"x-order-properties": [
"model",
"prompt",
"image_url",
"duration",
"resolution",
"aspect_ratio"
]
},
"PredictionResponse": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Unique identifier for the prediction."
},
"urls": {
"type": "object",
"description": "Object containing related API endpoints."
},
"model": {
"type": "string",
"description": "Model ID used for the prediction."
},
"status": {
"type": "string",
"description": "Status of the task: created, processing, completed, or failed."
},
"outputs": {
"type": "array",
"items": {
"type": "string"
},
"description": "Array of URLs to the generated video (empty when status is not completed)."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "ISO timestamp of when the request was created."
},
"has_nsfw_contents": {
"type": "array",
"items": {
"type": "boolean"
},
"description": "Array of boolean values indicating NSFW detection for each output."
}
}
}
},
"securitySchemes": {
"apiKeyAuth": {
"in": "header",
"name": "Authorization",
"type": "apiKey"
}
}
}
}# xai/grok-imagine-video/image-to-video
> xAI Grok Imagine Video animates a starting frame image with natural-language motion prompts at 480p or 720p.
## Overview
- **Submit endpoint (POST)**: `https://api.atlascloud.ai/api/v1/model/generateVideo` — start an async generation; returns a `prediction_id`
- **Poll endpoint (GET)**: `https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}` — poll this until the prediction finishes
- **Model ID**: `xai/grok-imagine-video/image-to-video`
## API Information
This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.
### Input Schema
The API accepts the following input parameters:
- **`model`** (`string`, _required_):
Model name.
- Default: `"xai/grok-imagine-video/image-to-video"`
- **`prompt`** (`string`, _required_):
Natural-language motion prompt. The starting frame is taken from the image.
- **`image_url`** (`string`, _required_):
Public HTTPS URL or base64 data URI of the starting-frame image (JPEG, PNG, or WebP).
- **`duration`** (`integer`, _optional_):
Length of generated video in seconds. Range: 1–15.
- Default: `8`
- Min: 1
- Max: 15
- **`resolution`** (`string`, _optional_):
Output resolution.
- Default: `"720p"`
- Options: "480p", "720p"
- **`aspect_ratio`** (`string`, _optional_):
Output aspect ratio. The default matches the input image; specifying a different value stretches the image.
- Default: `"16:9"`
- Options: "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"
**Required Parameters Example**:
```json
{
"model": "xai/grok-imagine-video/image-to-video",
"prompt": "",
"image_url": ""
}
```
**Full Example**:
```json
{
"model": "xai/grok-imagine-video/image-to-video",
"prompt": "",
"image_url": "",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}
```
### Output Schema
The API returns the following output format:
- **`id`** (`string`, _optional_):
Unique identifier for the prediction.
- **`urls`** (`object`, _optional_):
Object containing related API endpoints.
- **`model`** (`string`, _optional_):
Model ID used for the prediction.
- **`status`** (`string`, _optional_):
Status of the task: created, processing, completed, or failed.
- **`outputs`** (`array[string]`, _optional_):
Array of URLs to the generated video (empty when status is not completed).
- **`created_at`** (`string`, _optional_):
ISO timestamp of when the request was created.
- **`has_nsfw_contents`** (`array[boolean]`, _optional_):
Array of boolean values indicating NSFW detection for each output.
**Example Response**:
```json
{
"id": "",
"urls": {},
"model": "",
"status": "",
"outputs": [
""
],
"created_at": "",
"has_nsfw_contents": []
}
```
## Usage Examples
### cURL
```bash
# Step 1: Start generation (async)
curl -X POST "https://api.atlascloud.ai/api/v1/model/generateVideo" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "xai/grok-imagine-video/image-to-video",
"prompt": "",
"image_url": "",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9"
}'
# Response will contain: {"code": 200, "data": {"id": "prediction_id", "status": "processing"}}
# Step 2: Poll for result (replace {prediction_id} with the id returned above)
curl -X GET "https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY"
# Keep polling until status is "completed", "succeeded" or "failed"
# When completed, outputs will contain the generated content URL(s)
```
## Additional Resources
### Documentation
- [Model Playground](https://www.atlascloud.ai/models/xai/grok-imagine-video/image-to-video)
The astronaut slowly walks forward
The astronaut slowly walks forward