接入介绍
Pika 未开放官方 API,其能力与 GPTs 类似,是通过第三方渠道对接而来。 可做文生视频与图生视频。 按次计费,一次生成一个视频。
创建视频任务
text
curl 'https://{base_url}/pika/generate' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ***' \
--data '{"pikaffect":"","promptText":"moving","model":"1.5","options":{"aspectRatio":1.7777777777777777,"frameRate":24,"camera":{},"parameters":{"guidanceScale":12,"motion":1,"negativePrompt":""},"extend":false}}'
请求体示例:
text
{
"pikaffect": "",
"model": "1.5",
"promptText": "moving",
"image": "",
"options": {
"aspectRatio": 1.7777777777777777,
"frameRate": 24,
"camera": {},
"parameters": { "guidanceScale": 12, "motion": 1, "negativePrompt": "" },
"extend": false
}
}
关键字段说明
- pikaffect(string):官方视频效果,可留空;配置效果后会带配音。当前可选:Levitate、Decapitate、Eye-pop、Ta-da、Deflate、Crumble、Dissolve、Squish、Inflate、Melt、Crush、Cake-ify、Explode,官方后续可能继续增加。
- promptText(string):提示词。
- image(string):一旦传入就必须有值,可以是 base64 或图片 url。
- model(string):模型版本,1.5 或 2.0。
- options(object):视频设置。
- options.aspectRatio(number):宽高比例;使用图片输入时需去掉该字段。
- options.parameters.negativePrompt(string):不希望在画面中出现的物体。
返回体
返回的 id 即 taskId,后续步骤会用到。
text
{
"id": "b7f0c2d4-9a31-4e58-8c07-2d5fa6e0b913"
}
查看任务状态
text
curl 'https://{base_url}/pika/feed/{id}' \
-H 'Authorization: Bearer ***'
返回体
text
{
"id": "b7f0c2d4-9a31-4e58-8c07-2d5fa6e0b913",
"promptText": "Plane fly",
"videos": [
{
"id": "b7f0c2d4-9a31-4e58-8c07-2d5fa6e0b913",
"status": "finished",
"seed": 1902358417,
"resultUrl": "https://<结果地址>/Plane_fly_seed1902358417.mp4",
"sharingUrl": "https://<分享地址>/Plane_fly_seed1902358417_share.mp4",
"videoPoster": "https://<封面地址>/poster.jpg",
"imageThumb": "https://<缩略图地址>/thumbnail.jpg",
"duration": 5,
"error": "",
"progress": 100
}
]
}
返回关键字段说明
- id(string):任务 id。
- promptText(string):提示词。
- videos(array):视频数组。
- videos[].id(string):视频 id。
- videos[].status(string):视频状态,finished 为完成,error 为出错。
- videos[].seed(number):视频种子。
- videos[].resultUrl(string):视频地址。
- videos[].videoPoster(string):封面图片。
- videos[].sharingUrl(string):视频分享地址。
- videos[].error(string):状态为 error 时给出错误说明。
- videos[].progress(number):进度。
ingredient:多图创建视频任务
三个前提:请求体内不能带 image;ingredient 传图片数组,元素可以是 url 或 base64;model 必须为 2.0。ingredients-mode 可选 precise(精确模式)或 creative(创意模式)。
请求体示例:
text
{
"pikaffect": "",
"model": "2.0",
"promptText": "pick it",
"ingredient": [
"https://<图片地址>/a.png",
"https://<图片地址>/b.jpg"
],
"options": {
"aspectRatio": 1.7777777777777777,
"frameRate": 24,
"camera": {},
"parameters": { "guidanceScale": 12, "motion": 1, "negativePrompt": "" },
"extend": false,
"ingredients-mode": "precise"
}
}
说明:原页面示例里的第三方域名与图片地址已按合规要求替换为占位符,示例序号改为示意值。