cURL
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."
}Grok
关键帧生视频
关键帧生视频 - 通过 keyframes 在视频中间指定关键帧图像,可与首帧和尾帧组合使用
POST
/
grok
/
generations
cURL
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."
}这是 Grok 视频 API 的关键帧生视频接口。通过
keyframes 在视频中间指定关键帧图像,模型会在关键帧之间生成过渡画面。可与 first_frame(首帧)和 last_frame(尾帧)组合使用,支持以下组合方式:
- 首帧 + 关键帧:指定视频开头和中间关键帧
- 关键帧 + 尾帧:指定中间关键帧和视频结尾
- 首帧 + 关键帧 + 尾帧:完整控制视频的首帧、中间关键帧和尾帧
grok-imagine-video-1.5-fast 和 grok-imagine-video-1.5。
注意:不允许 NSFW 内容。单次或偶尔的审核失败不会产生任何费用,但反复触发审核失败可能会产生扣费。
关键帧限制:每个请求最多 4 个关键帧;
timestamp_s 必须大于 0 且小于视频时长;关键帧之间至少间隔 1/3 秒。请求体
application/json
关键帧生视频请求参数
提示词,用于引导关键帧之间的运动和镜头。可选。
关键帧数组。每个元素包含一个图片地址和对应的时间戳(秒)。最多 4 个关键帧。timestamp_s 必须大于 0 且小于视频时长,关键帧之间至少间隔 1/3 秒。
Maximum array length:
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 首帧图片地址。用于严格指定视频的第一帧。可与 keyframes 和 last_frame 组合使用。
尾帧图片地址。用于严格指定视频的最后一帧。可与 keyframes 和 first_frame 组合使用。当 first_frame 和 last_frame 传入同一张图片时,实现循环效果(loop)。
回调地址,任务完成或失败将通过请地址进行通知,通知数据结构与fetch结构 [blocked]一致。如果未设置,则需要请求fetch接口 [blocked]进行查询
示例:
"https://example.com/callback"
最后修改于 2026年10月11日