Grok 文本转视频
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/grok-text-to-video \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "A cat playing with a ball in slow motion",
"aspect_ratio": "2:3",
"mode": "normal"
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/grok-text-to-video"
payload = {
"prompt": "A cat playing with a ball in slow motion",
"aspect_ratio": "2:3",
"mode": "normal"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'A cat playing with a ball in slow motion',
aspect_ratio: '2:3',
mode: 'normal'
})
};
fetch('https://api.sinancode.com/v1/generate/k/grok-text-to-video', 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.sinancode.com/v1/generate/k/grok-text-to-video",
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' => 'A cat playing with a ball in slow motion',
'aspect_ratio' => '2:3',
'mode' => 'normal'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.sinancode.com/v1/generate/k/grok-text-to-video"
payload := strings.NewReader("{\n \"prompt\": \"A cat playing with a ball in slow motion\",\n \"aspect_ratio\": \"2:3\",\n \"mode\": \"normal\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.sinancode.com/v1/generate/k/grok-text-to-video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"A cat playing with a ball in slow motion\",\n \"aspect_ratio\": \"2:3\",\n \"mode\": \"normal\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/grok-text-to-video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"A cat playing with a ball in slow motion\",\n \"aspect_ratio\": \"2:3\",\n \"mode\": \"normal\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}视频生成 - Grok
Grok 文生视频
使用 xAI Grok 模型从文本生成视频(异步)
POST
/
generate
/
k
/
grok-text-to-video
Grok 文本转视频
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/grok-text-to-video \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "A cat playing with a ball in slow motion",
"aspect_ratio": "2:3",
"mode": "normal"
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/grok-text-to-video"
payload = {
"prompt": "A cat playing with a ball in slow motion",
"aspect_ratio": "2:3",
"mode": "normal"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'A cat playing with a ball in slow motion',
aspect_ratio: '2:3',
mode: 'normal'
})
};
fetch('https://api.sinancode.com/v1/generate/k/grok-text-to-video', 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.sinancode.com/v1/generate/k/grok-text-to-video",
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' => 'A cat playing with a ball in slow motion',
'aspect_ratio' => '2:3',
'mode' => 'normal'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.sinancode.com/v1/generate/k/grok-text-to-video"
payload := strings.NewReader("{\n \"prompt\": \"A cat playing with a ball in slow motion\",\n \"aspect_ratio\": \"2:3\",\n \"mode\": \"normal\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.sinancode.com/v1/generate/k/grok-text-to-video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"A cat playing with a ball in slow motion\",\n \"aspect_ratio\": \"2:3\",\n \"mode\": \"normal\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/grok-text-to-video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"A cat playing with a ball in slow motion\",\n \"aspect_ratio\": \"2:3\",\n \"mode\": \"normal\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}使用 xAI 的 Grok Imagine 模型从文本生成短视频。
模型特点:
- 极速生成 - 15 秒内完成视频生成,速度优于 Sora 2
- 音视频同步 - 原生集成音频生成,自动添加音效和背景音乐
- 流畅动作 - 24fps 流畅帧率,复杂动作无变形
- 智能运镜 - 支持动态镜头效果和智能焦点切换
授权
请使用您的 API Token 进行认证
请求体
application/json
任务参数
响应
OK
Task ID
示例:
"01234567-89ab-cdef-0123-456789abcdef"
⌘I