Grok 视频生成
curl --request POST \
--url https://octopusx.ai/v1/videos \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"aspect_ratio": "<string>",
"seconds": 123,
"size": "<string>"
}
'import requests
url = "https://octopusx.ai/v1/videos"
payload = {
"model": "<string>",
"prompt": "<string>",
"aspect_ratio": "<string>",
"seconds": 123,
"size": "<string>"
}
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({
model: '<string>',
prompt: '<string>',
aspect_ratio: '<string>',
seconds: 123,
size: '<string>'
})
};
fetch('https://octopusx.ai/v1/videos', 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://octopusx.ai/v1/videos",
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([
'model' => '<string>',
'prompt' => '<string>',
'aspect_ratio' => '<string>',
'seconds' => 123,
'size' => '<string>'
]),
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://octopusx.ai/v1/videos"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seconds\": 123,\n \"size\": \"<string>\"\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://octopusx.ai/v1/videos")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seconds\": 123,\n \"size\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://octopusx.ai/v1/videos")
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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seconds\": 123,\n \"size\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "video_abc123",
"object": "video",
"model": "grok-video-3",
"status": "queued",
"progress": 0,
"created_at": 1735689600,
"size": "720P"
}
{
"error": {
"message": "prompt is required",
"type": "new_api_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "无效的令牌",
"type": "new_api_error",
"param": "",
"code": "invalid_api_key"
}
}
OpenAI 格式
Grok 视频生成
使用 POST /v1/videos 调用 Grok 视频系列模型提交异步生成任务。
POST
https://octopusx.ai
/
v1
/
videos
Grok 视频生成
curl --request POST \
--url https://octopusx.ai/v1/videos \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"aspect_ratio": "<string>",
"seconds": 123,
"size": "<string>"
}
'import requests
url = "https://octopusx.ai/v1/videos"
payload = {
"model": "<string>",
"prompt": "<string>",
"aspect_ratio": "<string>",
"seconds": 123,
"size": "<string>"
}
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({
model: '<string>',
prompt: '<string>',
aspect_ratio: '<string>',
seconds: 123,
size: '<string>'
})
};
fetch('https://octopusx.ai/v1/videos', 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://octopusx.ai/v1/videos",
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([
'model' => '<string>',
'prompt' => '<string>',
'aspect_ratio' => '<string>',
'seconds' => 123,
'size' => '<string>'
]),
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://octopusx.ai/v1/videos"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seconds\": 123,\n \"size\": \"<string>\"\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://octopusx.ai/v1/videos")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seconds\": 123,\n \"size\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://octopusx.ai/v1/videos")
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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seconds\": 123,\n \"size\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "video_abc123",
"object": "video",
"model": "grok-video-3",
"status": "queued",
"progress": 0,
"created_at": 1735689600,
"size": "720P"
}
{
"error": {
"message": "prompt is required",
"type": "new_api_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "无效的令牌",
"type": "new_api_error",
"param": "",
"code": "invalid_api_key"
}
}
Grok 视频生成
OpenAI 格式入口。若需使用统一视频的POST /v1/video/create,请见 创建视频。
Grok 视频生成接口使用 multipart/form-data 提交,请按这里的字段组织请求。
- 接口路径是
POST /v1/videos。 input_reference是参考图字段,支持重复上传多张图片。grok-video-3-pro会自动固定为10秒,grok-video-3-max会自动固定为15秒。- 基础版
grok-video-3没有额外固定秒数逻辑,按实际传参处理。
当前可用模型
grok-video-3grok-video-3-progrok-video-3-max
方法与路径
POST /v1/videos
请求示例
curl -X POST https://octopusx.ai/v1/videos \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=grok-video-3" \
-F "prompt=猫咪听歌摇头晃脑,下大雨" \
-F "aspect_ratio=2:3" \
-F "seconds=6" \
-F "size=720P" \
-F "input_reference=@reference.png"
import requests
with open("reference.png", "rb") as f:
resp = requests.post(
"https://octopusx.ai/v1/videos",
headers={"Authorization": "Bearer YOUR_API_KEY"},
data={
"model": "grok-video-3",
"prompt": "猫咪听歌摇头晃脑,下大雨",
"aspect_ratio": "2:3",
"seconds": 6,
"size": "720P",
},
files={"input_reference": ("reference.png", f, "image/png")},
timeout=60,
)
print(resp.json())
const formData = new FormData();
formData.append("model", "grok-video-3");
formData.append("prompt", "猫咪听歌摇头晃脑,下大雨");
formData.append("aspect_ratio", "2:3");
formData.append("seconds", "6");
formData.append("size", "720P");
formData.append("input_reference", fileInput.files[0]);
const response = await fetch("https://octopusx.ai/v1/videos", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
body: formData,
});
console.log(await response.json());
响应示例
{
"id": "video_abc123",
"object": "video",
"model": "grok-video-3",
"status": "queued",
"progress": 0,
"created_at": 1735689600,
"size": "720P"
}
{
"error": {
"message": "prompt is required",
"type": "new_api_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "无效的令牌",
"type": "new_api_error",
"param": "",
"code": "invalid_api_key"
}
}
认证
Authorization: Bearer YOUR_API_KEY
Body
模型名称。当前 Grok 系列可用值为
grok-video-3、grok-video-3-pro、grok-video-3-max。提示词。
视频尺寸比例。可选为 16:9, 9:16, 2:3, 3:2, 1:1。
目标秒数。对
grok-video-3-pro 和 grok-video-3-max,会自动纠正为固定值。分辨率档位,常用值是
720P 或 1080P。参考图文件。可重复传多次,对应多张
input_reference 上传。Response
任务 ID。
固定为
video。实际提交的模型名。
任务状态,常见值有
queued、processing、completed、failed、cancelled。进度百分比。
创建时间戳。
输出清晰度档位。
使用场景
文生视频
只传model、prompt、seconds、size 这组字段即可。
图生视频
在文生视频的基础上追加一个或多个input_reference 文件。
固定时长模型
如果你传的是grok-video-3-pro 或 grok-video-3-max,应预期服务端按固定秒数处理。
相关接口
⌘I