视频内容获取
curl --request GET \
--url 'https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content' \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content', 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.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body视频系列
视频内容获取
通过内容代理接口获取视频文件本体
GET
{llmApiOrigin}
/
v1
/
videos
/
{task_id}
/
content
视频内容获取
curl --request GET \
--url 'https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content' \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content', 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.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/v1/videos/{task_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body简介
视频内容获取接口/v1/videos/{task_id}/content 用于获取已完成任务的视频文件本体(返回原始的 video/mp4 字节流),服务端会从上游拉取并把视频数据转发给你。
与你手里的几个接口的关系:
- 部分渠道的查询响应会直接返回视频
url,可直接下载; - 本接口适合:上游返回的是
data:URL、地址带签名易过期、或你希望由服务端统一代理转发视频的场景; - 也适用于通过各种入口(统一视频接口、OpenAI 视频接口、Seedance/Kling/即梦)提交的任务,只要任务已成功。
认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx请求
GEThttps://api.shengmoai.com/v1/videos/{task_id}/content
string
必填
视频任务 ID,由提交接口返回(
task_ 前缀)curl -L "https://api.shengmoai.com/v1/videos/video_69095b4ce0048190893a01510c0c98b0/content" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-o result.mp4
响应
成功时返回视频文件本体(不是 JSON),Content-Type 为 video/mp4,并带有 Cache-Control: public, max-age=86400。
任务尚未完成时返回:
{
"error": {
"message": "Task is not completed yet, current status: processing",
"type": "invalid_request_error"
}
}
404,失败原因以查询接口的 status / error 为准。
使用示例
下载保存文件
curl -L "https://api.shengmoai.com/v1/videos/video_xxxx/content" \
-H "Authorization: Bearer sk-xxxxxxxxxx" -o video.mp4
前端播放
浏览器拿到的是完整 mp4 字节流,可以直接作为<video> 的源:
<video src="https://your-docs-domain/v1/videos/video_xxx/content" controls></video>
前端直接使用需要在请求头携带 Authorization;如需公开播放,请由业务后端代拉后再输出。
注意事项
- 该接口只返回已完成任务的视频;任务还在排队/生成时请先轮询状态。
- 视频内容来自上游存储,可能较大(数 MB ~ 上百 MB),下载与转存请考虑耗时与并发。
- 文件会缓存 24 小时(
max-age=86400),重复请求会命中缓存,适合测试与调试。
相关接口
视频生成总览
异步流程、入口选择与状态对照
OpenAI 视频接口
/v1/videos 系列:提交、查询与 Remix