Api

API 错误

ViewMax v1 错误信封、HTTP 状态码、全部错误消息,以及何时重试。

错误响应

每个 v1 错误都是包含 code、message 和 error 对象的 JSON,没有 data。

{
  "code": -1,
  "message": "viewmax-c1 text-to-video supports duration 1s|2s|3s|4s|5s|6s|7s|8s|9s|10s|11s|12s|13s|14s|15s, got 30s",
  "error": {
    "type": "invalid_request",
    "hint": "Fix the request using this message, then retry. Refresh GET /api/v1/models before repeating an unsupported model or option.",
    "docs": "https://viewmax.studio/docs/api/errors"
  }
}
字段说明
code-1、-1001(未认证)或 -1002(积分不足)
message出错原因,消息列表见下文
error.typeinvalid_request、content_rejected、unauthorized、insufficient_credits、not_found 或 internal_error
error.hint下一步操作,包括重试是否有用
error.docs文档链接
error.task_id请求在失败前已创建任务时出现

状态码

HTTPcodeerror.type何时出现是否重试?
400-1invalid_request请求、模型、模式或选项无效,或模型拒绝了这些设置否,先修正请求
400-1content_rejected提示词或源素材被安全检查拒绝否,更换内容
401-1001unauthorized缺少或无效的 API key否,发送有效 key
402-1002insufficient_credits余额低于费用,未创建任务否,先充值
404-1not_found任务不存在、属于其他账户,或端点不存在否
405——路径存在但不支持此方法,响应体为空否,使用文档中的方法
500-1internal_error服务商或服务器故障检查 error.task_id 后重试一次
503-1internal_error内容安全检查暂时不可用是,稍后重试

是否应该重试?

  1. 400、401、402、404:不要重复同一请求,按消息修正。
  2. 503:稍后重试同一请求。
  3. 没有 error.task_id 的 500:稍等片刻后重试一次。
  4. 任何带 error.task_id 的错误:先查询 GET /api/v1/tasks/{task_id}。
    • failed:积分已退回。阅读失败载荷,必要时再创建新任务。
    • pending 或 processing:模型仍可能交付该任务。请继续轮询而不是重试;新请求会再次扣费。
  5. 重试创建请求时,如果不确定第一次请求是否到达 ViewMax,请复用同一个 Idempotency-Key。已存在的任务会直接返回,不会重复扣费。

Idempotency-Key

在每个创建请求上发送 Idempotency-Key:POST /api/v1/videos、images、music、speech 和 sound-effects。

  • key 为 1–200 个可见 ASCII 字符、不含空格,例如 UUID。其他格式返回 400,消息为 Idempotency-Key must be 1-200 visible ASCII characters without spaces。
  • 重复的 key 返回首次请求创建的任务及其原始 costCredits,不会扣费。不会比较请求体。
  • key 的作用域是你的账户,在所有创建端点间共享。
  • 即使原任务已失败,重放也会返回它。新的尝试请使用新 key。
  • 不带该请求头时,每个 POST 都会创建并扣费一个新任务。

400 invalid_request 消息

尖括号表示随请求变化的值。

所有创建端点

消息原因处理
JSON 解析器消息,例如 Unexpected end of JSON input请求体不是合法 JSON使用 Content-Type: application/json 发送 JSON 对象
request body must be an object请求体是 JSON 但不是对象发送 JSON 对象
Idempotency-Key must be 1-200 visible ASCII characters without spacesIdempotency-Key 请求头格式错误使用 UUID 或其他短令牌
model is required缺少 model(videos、images)发送 GET /api/v1/models 中的 ID
prompt is required缺少 prompt 或为空发送非空提示词
options must be an objectoptions 不是对象以 JSON 对象发送 options
image_urls must be an array of URLsimage_urls 不是字符串数组发送公开 HTTP(S) URL 数组
This capability is unavailable.模型或模式已停用,例如 Motion Control换用其他模型;重试仍会失败
the generation request uses unsupported settings任务创建后模型拒绝了这些设置。任务已失败并退款,error.task_id 有值读取该任务的 taskInfo.errorMessage,调整后创建新任务
invalid params or unsupported model for scene该模型不支持此模式从目录中选择模型和模式

视频(POST /api/v1/videos)

消息原因处理
video_urls must be an array of URLsvideo_urls 不是字符串数组发送公开 HTTP(S) URL 数组
mode must be one of text-to-video|image-to-video|video-to-video|frames-to-video|reference-to-video, got <mode>未知模式使用五种模式 ID 之一
unsupported video model: <model>未知模型 ID使用 GET /api/v1/models 中的 id
video model temporarily unavailable: <model>. The provider is not serving this model right now — pick a different model.模型已下线,例如 sora-2换用其他模型
<model> does not support mode <mode>模式不在该模型的 modes 中选择列出的模式
<model> prompt must be <max> characters or fewer, got <length>去除首尾空白后的提示词超过 max_prompt_length缩短提示词
image_urls must contain valid http(s) URLsURL 不是以 http:// 或 https:// 开头发送公开 HTTP(S) URL(video_urls 同理)
<model> <mode> requires image_urls该模式需要图片添加图片 URL
<model> <mode> requires image_urls (at least 2)frames-to-video 需要首帧和尾帧发送两个图片 URL
<model> <mode> requires video_urlsvideo-to-video 需要源视频添加一个视频 URL
<model> <mode> does not accept image_urls; supported inputs: <inputs>该模式不接受图片(或视频)移除该输入或换用其他模式
<model> <mode> supports at most <n> image_urls, got <count>输入过多(video_urls 同理)减少 URL 数量
<model> <mode> requires options.source_video_duration_seconds when video_urls is provided按秒计费的模型收到了视频发送源视频时长(秒)
<model> <mode> supports duration <values>, got <value>不支持的 duration使用该模式 durations 中的值
<model> <mode> supports duration <values> at <resolution>, got <value>该分辨率下不提供此时长调整时长或分辨率
<model> <mode> supports resolution <values>, got <value>不支持的 resolution(列表为空表示不要发送)使用 resolutions 中的值,或省略
<model> <mode> supports aspect_ratio <values>, got <value>不支持的 aspect_ratio使用 aspect_ratios 中的值,或省略
<model> <mode> supports audio false, got true该模式没有音频开关移除 audio 或发送 false

示例:kling-2-6 text-to-video supports duration 5s|10s, got 30s;runway text-to-video supports duration 5s at 1080p, got 10s。

图片、音乐、语音和音效

消息端点处理
scene must be one of text-to-image|image-to-image, got <scene>images使用列出的 scene
unsupported image model: <model>. Supported models: <ids>images使用 GET /api/v1/models?type=image 中的 ID
<model> supports scene <scenes>, got <scene>images选择该模型支持的 scene
image-to-image requires image_urlsimages添加图片 URL
Invalid GPT Image 2.5 quality、resolution、aspect ratio 或 pixel dimensionsimages使用 GPT Image 2.5 模型列出的值
options.duration_seconds must be a number from 3 to 300music发送 3 到 300 之间的数字
options.duration is not supported; use options.duration_secondsmusic改用 duration_seconds(music_length_ms 同理)
text is required、voice_id is requiredspeech两个字段都要发送
unknown voice_id: <id>. Call GET /api/v1/voices (MCP: list_voices) for available voices.speech使用 GET /api/v1/voices 中的 ID
options.duration_seconds must be a number from 0.5 to 22sound-effects发送范围内的数字
options.prompt_influence must be a number from 0 to 1sound-effects发送范围内的数字

400 content_rejected 消息

消息原因处理
input content was rejected by safety filters提示词提及禁止用途(deepfake、换脸或冒充他人)。在创建任务和扣费前检查,即使出现在否定指令中(如“不要换脸”)也会命中删除相关措辞;原样重试仍会失败
input content was rejected by safety filters任务创建后模型审核拒绝了提示词或素材。任务已失败并退款,error.task_id 有值更换内容后创建新任务
Prompt was blocked by content safety review.内容安全审核拦截了提示词修改提示词

其他状态

HTTP消息说明
401unauthorized参见认证
402insufficient credits在创建任务前检查,包括两个请求争用同一余额的情况。error.docs 指向价格页
404task not found任务 ID 不存在或属于其他账户
404endpoint not found未知的 /api/... 路径。参见 OpenAPI
500the generation service is temporarily unavailable模型服务故障或无响应。重试前检查 error.task_id
500media generation failed其他失败。重试前检查 error.task_id
500the generation service is busy; try again later模型服务限流,稍后重试
500the generation request was cancelled请求在上游被取消,重试一次
503Content safety check is temporarily unavailable. Please try again in a moment.稍后重试

轮询 GET /api/v1/tasks/{taskId} 时出现的 500 是暂时性的:继续轮询同一任务即可。

On this page