yikart/AiToEarn · error · BadRequestException
first_frame/last_frame and reference media cannot be mixed
Error message
first_frame/last_frame and reference media cannot be mixed
What it means
Volcengine generation modes are mutually exclusive: first_frame/last_frame (frame interpolation) cannot be combined with reference-based (image-to-video / reference media) generation. validateContent throws this BadRequestException when both a frame scene and a reference scene (reference image, video, or audio) are present.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts:175
const referenceAudios = audioContents.filter(item => item.role === AudioRole.ReferenceAudio)
const hasFrameScene = firstFrameImages.length > 0 || lastFrameImages.length > 0
const hasReferenceScene = referenceImages.length > 0 || referenceVideos.length > 0 || referenceAudios.length > 0
if (firstFrameImages.length > 1) {
throw new BadRequestException('Only one first frame image is allowed')
}
if (lastFrameImages.length > 1) {
throw new BadRequestException('Only one last frame image is allowed')
}
if (lastFrameImages.length > 0 && firstFrameImages.length === 0) {
throw new BadRequestException('last_frame requires first_frame')
}
if (hasFrameScene && hasReferenceScene) {
throw new BadRequestException('first_frame/last_frame and reference media cannot be mixed')
}
if (referenceAudios.length > 0 && referenceImages.length === 0 && referenceVideos.length === 0) {
throw new BadRequestException('reference_audio requires at least one reference image or reference video')
}
}
private normalizeRequest(request: UserVolcengineGenerationRequestDto) {
let prompt = ''
let inlineResolution: string | undefined
let inlineRatio: string | undefined
let inlineDuration: number | undefined
let inlineSeed: number | undefined
let inlineWatermark: boolean | undefined
const normalizedContent = request.content.map((item) => {
if (item.type !== ContentType.Text) {
return itemView on GitHub (pinned to d3aa8bea5b)
Solutions
- Choose one mode: either frame interpolation (first/last frame only) or reference-based generation (reference media only)
- Split into two separate generation requests if both are needed
- Clear frame-role items when the user switches to reference mode in the UI
Example fix
// before
content: [{first_frame}, {reference_image}]
// after
content: [{type:'image_url', role:'reference_image', url: img}] // or keep only the frame pair Defensive patterns
Strategy: validation
Validate before calling
const frameRoles = ['first_frame','last_frame']; const hasFrame = content.some(c => frameRoles.includes(c.role)); const hasRef = content.some(c => ['reference_image','reference_video','reference_audio'].includes(c.role)); if (hasFrame && hasRef) throw new Error('frame and reference modes are mutually exclusive') Type guard
const isExclusiveMode = (c: Content[]) => { const f = c.some(i => ['first_frame','last_frame'].includes(i.role)); const r = c.some(i => ['reference_image','reference_video','reference_audio'].includes(i.role)); return !(f && r) } Try / catch
try { await generate(req) } catch (e) { if (e instanceof BadRequestException && e.message.includes('cannot be mixed')) { /* split into two requests: one per mode */ } else throw e } Prevention
- Reset frame-role selections when switching to reference mode in UI
- Model the two modes as separate request types in client code
- Never append all uploads into one content array blindly
When it happens
Trigger: Content array containing first_frame and/or last_frame images together with any reference_image, reference_video, or reference_audio items.
Common situations: Clients appending all media in one array without knowing modes are exclusive; UI accumulating uploaded images across mode switches; migration code merging two requests.
Related errors
- image_tail requires a single first frame image
- content is required
- Only one first frame image is allowed
- Only one last frame image is allowed
- last_frame requires first_frame
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/81401f5af8e39ba0.
Report an issue: GitHub.