API Документация
Справочник API
Документация для интеграции
REST API
JSON Ответы
Генерация видео
Аутентификация
Bearer Token
Authorization: Bearer your-api-token-here
Безопасность: Не раскрывайте токен
Базовый URL
Адрес запросов:
https://grokimagineapi.com
Эндпоинты
POST
Создать видео
/v1/generateГенерация видео
Тело
{
"mode": "fun",
"prompt": "a beautiful landscape with mountains",
"images": ["https://example.com/image.png"],
"ratio": "1:1"
}Параметры
| Параметр | Тип | Описание |
|---|---|---|
| mode | string | Режим |
| prompt | string | Промпт |
| images | string? | Изображения |
| ratio | string | Соотношение |
💰 Pricing
Each generation consumes 40 credits, approximately 0.4 USD
Ответ
{
"code": 200,
"message": "success",
"data": {
"task_id": "task_123456789"
}
}cURL Example
curl -X POST https://grokimagineapi.com/v1/generate \
-H "Authorization: Bearer your-api-token" \
-H "Content-Type: application/json" \
-d '{
"mode": "fun",
"prompt": "a beautiful landscape with mountains",
"ratio": "1:1"
}'GET
Статус задачи
/v1/status?task_id=xxxxПроверка статуса
Параметры
GET запрос task_id=xxxx
Response
{
"code": 200,
"message": "success",
"data": {
"consumed_credits": 40,
"created_at": "2024-01-01T00:00:00Z",
"status": "completed",
"task_id": "task_123456789",
"error_message": null,
"request": {
"mode": "fun",
"prompt": "a beautiful landscape with mountains",
"ratio": "1:1"
},
"response": [
"https://cdn.example.com/generated/video1.mp4",
"https://cdn.example.com/generated/video2.mp4"
]
}
}Поля ответа
- consumed_credits: Кредиты
- created_at: Создано
- status: Статус
- task_id: ID задачи
- error_message: Error details if the task failed. Examples: 'File type not supported', 'Inappropriate content, please try another prompt.', 'grok imagine build failed', 'Network error, please try again later.'
- request: Запрос
- response: Ответ
cURL Example
curl -X GET "https://grokimagineapi.com/v1/status?task_id=task_123456789" \ -H "Authorization: Bearer your-api-token"
Ошибки
Коды
Коды HTTP
200OK
400Bad Request
401Unauthorized
429Rate Limited
500Server Error
Формат
{
"code": 400,
"message": "Invalid request: The prompt parameter is required",
"error": "INVALID_REQUEST"
}Практика: Обрабатывайте ошибки
Лимиты
100
запр/мин
Бесплатно
1000
requests/minute
Pro
5000
requests/minute
Enterprise
Заголовки лимитов: Заголовки X-RateLimit-Remaining и X-RateLimit-Reset