yikart/AiToEarn · error · BadRequestException
OpenAI does not support multiple images
Error message
OpenAI does not support multiple images
What it means
OpenAI's Sora-2 video generation API only accepts a single reference image as `input_reference`. The service throws a BadRequestException during createFromRequest when the caller passes an array of images, because the OpenAI provider cannot map multiple images onto its API contract. Other providers in this service may support image arrays; OpenAI does not.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/openai/openai.service.ts:52
return undefined
}
const parsed = this.storageProvider.parsePathFromUrl(url)
if (parsed.startsWith('http')) {
return url
}
return this.storageProvider.toPresignedUrl(url)
}
private async resolveRelayText(text: string): Promise<string> {
if (!this.relayMediaResolver) {
return text
}
return await this.relayMediaResolver.resolveText(text)
}
async createFromRequest(request: UserVideoGenerationRequestDto): Promise<{ id: string }> {
if (Array.isArray(request.image)) {
throw new BadRequestException('OpenAI does not support multiple images')
}
const result = await this.createVideo({
userId: request.userId,
userType: request.userType,
prompt: request.prompt,
input_reference: await this.toAccessibleUrl(request.image),
model: request.model as 'sora-2' | 'sora-2-pro',
seconds: request.duration ? request.duration.toString() as '10' | '15' | '25' : undefined,
size: request.size as '720x1280' | '1280x720' | '1024x1792' | '1792x1024' | undefined,
})
return { id: result.id }
}
/**
* OpenAI 视频创建
*/View on GitHub (pinned to d3aa8bea5b)
Solutions
- Send only a single image (a string) in request.image when targeting the OpenAI provider
- Route the request to a provider that supports multiple reference images
- Add upstream validation that rejects/reduces multi-image requests before they reach the OpenAI channel
Example fix
// before image: ['https://cdn.example.com/a.png', 'https://cdn.example.com/b.png'] // after image: 'https://cdn.example.com/a.png'
Defensive patterns
Strategy: validation
Validate before calling
if (Array.isArray(request.image) && request.image.length > 1) {
throw new Error('OpenAI provider supports only a single reference image')
} Type guard
function isSingleImage(image: string | string[] | undefined): image is string | undefined {
return !Array.isArray(image)
} Try / catch
try {
await ai.createVideoFromRequest({ ...req, image: singleImage })
} catch (e) {
if (e instanceof BadRequestException && e.message.includes('multiple images')) {
// downgrade to single image or re-route to multi-image provider
}
} Prevention
- Always send image as a string for OpenAI-targeted video requests
- Validate image cardinality per provider before dispatching from a unified API
- Document provider capability differences in the API schema descriptions
When it happens
Trigger: Calling createFromRequest (or the video generation endpoint routed to the OpenAI provider) with request.image being an array of URLs/paths, e.g. when the client sends multiple reference images and the request is dispatched to the openai channel instead of a multi-image provider.
Common situations: A unified video-generation API is shared across providers (OpenAI, Veo, etc.) and the client built a request with several images for another provider; provider routing then sends it to OpenAI. Also happens after frontend changes that always send images as an array.
Related errors
- video duration is required
- InvalidAiTaskId
- image_tail requires a single first frame image
- content is required
- text prompt is required
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/eabbe81af43ada61.
Report an issue: GitHub.