{"record":{"id":"eabbe81af43ada61","repo":"yikart/AiToEarn","slug":"openai-does-not-support-multiple-images","errorCode":null,"errorMessage":"OpenAI does not support multiple images","messagePattern":"OpenAI does not support multiple images","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/openai/openai.service.ts","lineNumber":52,"sourceCode":"      return undefined\n    }\n    const parsed = this.storageProvider.parsePathFromUrl(url)\n    if (parsed.startsWith('http')) {\n      return url\n    }\n    return this.storageProvider.toPresignedUrl(url)\n  }\n\n  private async resolveRelayText(text: string): Promise<string> {\n    if (!this.relayMediaResolver) {\n      return text\n    }\n    return await this.relayMediaResolver.resolveText(text)\n  }\n\n  async createFromRequest(request: UserVideoGenerationRequestDto): Promise<{ id: string }> {\n    if (Array.isArray(request.image)) {\n      throw new BadRequestException('OpenAI does not support multiple images')\n    }\n\n    const result = await this.createVideo({\n      userId: request.userId,\n      userType: request.userType,\n      prompt: request.prompt,\n      input_reference: await this.toAccessibleUrl(request.image),\n      model: request.model as 'sora-2' | 'sora-2-pro',\n      seconds: request.duration ? request.duration.toString() as '10' | '15' | '25' : undefined,\n      size: request.size as '720x1280' | '1280x720' | '1024x1792' | '1792x1024' | undefined,\n    })\n\n    return { id: result.id }\n  }\n\n  /**\n   * OpenAI 视频创建\n   */","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/openai/openai.service.ts#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nimage: ['https://cdn.example.com/a.png', 'https://cdn.example.com/b.png']\n// after\nimage: 'https://cdn.example.com/a.png'","handlingStrategy":"validation","validationCode":"if (Array.isArray(request.image) && request.image.length > 1) {\n  throw new Error('OpenAI provider supports only a single reference image')\n}","typeGuard":"function isSingleImage(image: string | string[] | undefined): image is string | undefined {\n  return !Array.isArray(image)\n}","tryCatchPattern":"try {\n  await ai.createVideoFromRequest({ ...req, image: singleImage })\n} catch (e) {\n  if (e instanceof BadRequestException && e.message.includes('multiple images')) {\n    // downgrade to single image or re-route to multi-image provider\n  }\n}","preventionTips":["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"],"tags":["openai","sora","validation","bad-request","api-contract"],"backgroundTag":"unsupported-provider-capability","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}