curl --request POST \
--url https://api.ttapi.io/grok/generations \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"prompt": "<string>",
"model": "grok-imagine-video-1.5-fast",
"aspect_ratio": "16:9",
"video_length": "10",
"resolution_name": "720p",
"first_frame": "https://example.com/first_frame.jpg",
"keyframes": [
{
"image": {
"url": "https://example.com/keyframe1.jpg"
},
"timestamp_s": 3
},
{
"image": {
"url": "https://example.com/keyframe2.jpg"
},
"timestamp_s": 6
}
],
"last_frame": "https://example.com/last_frame.jpg",
"hook_url": "https://example.com/callback"
}
'import requests
url = "https://api.ttapi.io/grok/generations"
payload = {
"prompt": "<string>",
"model": "grok-imagine-video-1.5-fast",
"aspect_ratio": "16:9",
"video_length": "10",
"resolution_name": "720p",
"first_frame": "https://example.com/first_frame.jpg",
"keyframes": [
{
"image": { "url": "https://example.com/keyframe1.jpg" },
"timestamp_s": 3
},
{
"image": { "url": "https://example.com/keyframe2.jpg" },
"timestamp_s": 6
}
],
"last_frame": "https://example.com/last_frame.jpg",
"hook_url": "https://example.com/callback"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'grok-imagine-video-1.5-fast',
aspect_ratio: '16:9',
video_length: '10',
resolution_name: '720p',
first_frame: 'https://example.com/first_frame.jpg',
keyframes: [
{image: {url: 'https://example.com/keyframe1.jpg'}, timestamp_s: 3},
{image: {url: 'https://example.com/keyframe2.jpg'}, timestamp_s: 6}
],
last_frame: 'https://example.com/last_frame.jpg',
hook_url: 'https://example.com/callback'
})
};
fetch('https://api.ttapi.io/grok/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ttapi.io/grok/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'model' => 'grok-imagine-video-1.5-fast',
'aspect_ratio' => '16:9',
'video_length' => '10',
'resolution_name' => '720p',
'first_frame' => 'https://example.com/first_frame.jpg',
'keyframes' => [
[
'image' => [
'url' => 'https://example.com/keyframe1.jpg'
],
'timestamp_s' => 3
],
[
'image' => [
'url' => 'https://example.com/keyframe2.jpg'
],
'timestamp_s' => 6
]
],
'last_frame' => 'https://example.com/last_frame.jpg',
'hook_url' => 'https://example.com/callback'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ttapi.io/grok/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"grok-imagine-video-1.5-fast\",\n \"aspect_ratio\": \"16:9\",\n \"video_length\": \"10\",\n \"resolution_name\": \"720p\",\n \"first_frame\": \"https://example.com/first_frame.jpg\",\n \"keyframes\": [\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe1.jpg\"\n },\n \"timestamp_s\": 3\n },\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe2.jpg\"\n },\n \"timestamp_s\": 6\n }\n ],\n \"last_frame\": \"https://example.com/last_frame.jpg\",\n \"hook_url\": \"https://example.com/callback\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ttapi.io/grok/generations")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"grok-imagine-video-1.5-fast\",\n \"aspect_ratio\": \"16:9\",\n \"video_length\": \"10\",\n \"resolution_name\": \"720p\",\n \"first_frame\": \"https://example.com/first_frame.jpg\",\n \"keyframes\": [\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe1.jpg\"\n },\n \"timestamp_s\": 3\n },\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe2.jpg\"\n },\n \"timestamp_s\": 6\n }\n ],\n \"last_frame\": \"https://example.com/last_frame.jpg\",\n \"hook_url\": \"https://example.com/callback\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/grok/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"grok-imagine-video-1.5-fast\",\n \"aspect_ratio\": \"16:9\",\n \"video_length\": \"10\",\n \"resolution_name\": \"720p\",\n \"first_frame\": \"https://example.com/first_frame.jpg\",\n \"keyframes\": [\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe1.jpg\"\n },\n \"timestamp_s\": 3\n },\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe2.jpg\"\n },\n \"timestamp_s\": 6\n }\n ],\n \"last_frame\": \"https://example.com/last_frame.jpg\",\n \"hook_url\": \"https://example.com/callback\"\n}"
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"message": "success",
"data": {
"jobId": "jobId"
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}Видео по ключевым кадрам
Видео по ключевым кадрам — закрепление изображений в выбранные моменты времени, с возможностью комбинации с первым и последним кадром
curl --request POST \
--url https://api.ttapi.io/grok/generations \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"prompt": "<string>",
"model": "grok-imagine-video-1.5-fast",
"aspect_ratio": "16:9",
"video_length": "10",
"resolution_name": "720p",
"first_frame": "https://example.com/first_frame.jpg",
"keyframes": [
{
"image": {
"url": "https://example.com/keyframe1.jpg"
},
"timestamp_s": 3
},
{
"image": {
"url": "https://example.com/keyframe2.jpg"
},
"timestamp_s": 6
}
],
"last_frame": "https://example.com/last_frame.jpg",
"hook_url": "https://example.com/callback"
}
'import requests
url = "https://api.ttapi.io/grok/generations"
payload = {
"prompt": "<string>",
"model": "grok-imagine-video-1.5-fast",
"aspect_ratio": "16:9",
"video_length": "10",
"resolution_name": "720p",
"first_frame": "https://example.com/first_frame.jpg",
"keyframes": [
{
"image": { "url": "https://example.com/keyframe1.jpg" },
"timestamp_s": 3
},
{
"image": { "url": "https://example.com/keyframe2.jpg" },
"timestamp_s": 6
}
],
"last_frame": "https://example.com/last_frame.jpg",
"hook_url": "https://example.com/callback"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'grok-imagine-video-1.5-fast',
aspect_ratio: '16:9',
video_length: '10',
resolution_name: '720p',
first_frame: 'https://example.com/first_frame.jpg',
keyframes: [
{image: {url: 'https://example.com/keyframe1.jpg'}, timestamp_s: 3},
{image: {url: 'https://example.com/keyframe2.jpg'}, timestamp_s: 6}
],
last_frame: 'https://example.com/last_frame.jpg',
hook_url: 'https://example.com/callback'
})
};
fetch('https://api.ttapi.io/grok/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ttapi.io/grok/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'model' => 'grok-imagine-video-1.5-fast',
'aspect_ratio' => '16:9',
'video_length' => '10',
'resolution_name' => '720p',
'first_frame' => 'https://example.com/first_frame.jpg',
'keyframes' => [
[
'image' => [
'url' => 'https://example.com/keyframe1.jpg'
],
'timestamp_s' => 3
],
[
'image' => [
'url' => 'https://example.com/keyframe2.jpg'
],
'timestamp_s' => 6
]
],
'last_frame' => 'https://example.com/last_frame.jpg',
'hook_url' => 'https://example.com/callback'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ttapi.io/grok/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"grok-imagine-video-1.5-fast\",\n \"aspect_ratio\": \"16:9\",\n \"video_length\": \"10\",\n \"resolution_name\": \"720p\",\n \"first_frame\": \"https://example.com/first_frame.jpg\",\n \"keyframes\": [\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe1.jpg\"\n },\n \"timestamp_s\": 3\n },\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe2.jpg\"\n },\n \"timestamp_s\": 6\n }\n ],\n \"last_frame\": \"https://example.com/last_frame.jpg\",\n \"hook_url\": \"https://example.com/callback\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ttapi.io/grok/generations")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"grok-imagine-video-1.5-fast\",\n \"aspect_ratio\": \"16:9\",\n \"video_length\": \"10\",\n \"resolution_name\": \"720p\",\n \"first_frame\": \"https://example.com/first_frame.jpg\",\n \"keyframes\": [\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe1.jpg\"\n },\n \"timestamp_s\": 3\n },\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe2.jpg\"\n },\n \"timestamp_s\": 6\n }\n ],\n \"last_frame\": \"https://example.com/last_frame.jpg\",\n \"hook_url\": \"https://example.com/callback\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/grok/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"grok-imagine-video-1.5-fast\",\n \"aspect_ratio\": \"16:9\",\n \"video_length\": \"10\",\n \"resolution_name\": \"720p\",\n \"first_frame\": \"https://example.com/first_frame.jpg\",\n \"keyframes\": [\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe1.jpg\"\n },\n \"timestamp_s\": 3\n },\n {\n \"image\": {\n \"url\": \"https://example.com/keyframe2.jpg\"\n },\n \"timestamp_s\": 6\n }\n ],\n \"last_frame\": \"https://example.com/last_frame.jpg\",\n \"hook_url\": \"https://example.com/callback\"\n}"
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"message": "success",
"data": {
"jobId": "jobId"
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}keyframes. Модель генерирует переходы между вашими опорными кадрами. Можно комбинировать с first_frame и last_frame:
- Первый кадр + ключевые кадры: указание начала и промежуточных кадров
- Ключевые кадры + последний кадр: указание промежуточных кадров и конца видео
- Первый кадр + ключевые кадры + последний кадр: полный контроль над началом, промежуточными кадрами и концом видео
grok-imagine-video-1.5-fast и grok-imagine-video-1.5.
timestamp_s должен быть больше 0 и меньше длительности видео; между ключевыми кадрами должно быть не менее 1/3 секунды.Авторизации
Вы можете получить API-ключ в панель управления TTAPI.
Тело
Параметры запроса генерации видео по ключевым кадрам
Промпт для управления движением и камерой между ключевыми кадрами. Необязательный.
Массив ключевых кадров. Каждый элемент содержит URL изображения и соответствующую временную метку в секундах. Максимум 4 ключевых кадра. timestamp_s должен быть больше 0 и меньше длительности видео; между ключевыми кадрами должно быть не менее 1/3 секунды.
4Show child attributes
Show child attributes
Название модели.
grok-imagine-video-1.5-fast, grok-imagine-video-1.5 "grok-imagine-video-1.5-fast"
Соотношение сторон видео
2:3, 3:2, 1:1, 9:16, 16:9 Длительность видео в секундах. grok-imagine-video-1.5-fast диапазон: от 6 до 30 (6 сек и 10 сек — стандартная длительность; 7 сек и 11 сек не поддерживаются); grok-imagine-video-1.5 диапазон: от 1 до 15.
Разрешение вывода. Доступные варианты: 480p, 720p.
480p, 720p, 1080p URL изображения первого кадра. Используется для строгого указания первого кадра видео. Можно комбинировать с keyframes и last_frame.
URL изображения последнего кадра. Используется для строгого указания последнего кадра видео. Можно комбинировать с keyframes и first_frame. Когда first_frame и last_frame используют одно и то же изображение, создаётся эффект зацикливания (loop).
Адрес обратного вызова URL. Когда задача будет выполнена или не выполнена, на этот адрес будут отправлены уведомления. Структура данных уведомления соответствует структуре получение результата [blocked]. Если не установлено, вам необходимо вызвать интерфейс получение результата [blocked] для запроса результата.
"https://example.com/callback"