yikart/AiToEarn · error · BadRequestException

text prompt is required

Error message

text prompt is required

What it means

After validating content, normalizeRequest extracts a plain-text prompt from text-type content items and throws this BadRequestException if the resulting prompt string is empty/whitespace. A non-empty text prompt is mandatory for Volcengine video generation regardless of media inputs.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts:214

      const parsed = parseModelTextCommand(item.text)
      if (!prompt && parsed.prompt) {
        prompt = parsed.prompt
      }
      inlineResolution = inlineResolution ?? parsed.params.resolution
      inlineRatio = inlineRatio ?? parsed.params.ratio
      inlineDuration = inlineDuration ?? parsed.params.duration
      inlineSeed = inlineSeed ?? parsed.params.seed
      inlineWatermark = inlineWatermark ?? parsed.params.watermark

      return {
        ...item,
        text: parsed.prompt,
      }
    })

    this.validateContent(normalizedContent)
    if (!prompt.trim()) {
      throw new BadRequestException('text prompt is required')
    }

    const aiLogRequest = {
      model: request.model,
      content: normalizedContent,
      return_last_frame: request.return_last_frame,
      resolution: request.resolution ?? inlineResolution,
      ratio: request.ratio ?? inlineRatio,
      duration: request.duration ?? inlineDuration,
      seed: request.seed ?? inlineSeed,
      watermark: request.watermark ?? inlineWatermark,
      tools: request.tools,
    }

    const requestBody: CreateVideoGenerationTaskRequest = {
      ...aiLogRequest,
      callback_url: config.ai.volcengine?.callbackUrl,
      safety_identifier: this.buildSafetyIdentifier(request.userId, request.userType),

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Include a text content item with a non-empty prompt
  2. Trim and check the prompt client-side before sending
  3. If the flow is image-driven, still supply a short descriptive prompt

Example fix

// before
content: [{ type:'image_url', role:'first_frame', url: img }]
// after
content: [{ type:'text', text: 'cinematic slow motion' }, { type:'image_url', role:'first_frame', url: img }]
Defensive patterns

Strategy: validation

Validate before calling

const prompt = content.filter(c => c.type === 'text').map(c => c.text).join(' ').trim(); if (!prompt) throw new Error('text prompt is required')

Type guard

const hasPrompt = (c: Content[]): c is [Extract<Content, {type: typeof ContentType.Text}>, ...Content[]] => c.some(i => i.type === ContentType.Text && i.text.trim().length > 0)

Try / catch

try { await generate(req) } catch (e) { if (e instanceof BadRequestException && e.message === 'text prompt is required') { /* surface a required-prompt error to the user */ } else throw e }

Prevention

When it happens

Trigger: Calling generation with content containing only media URLs (images/videos/audio) and no text item, or a text item with an empty/whitespace string.

Common situations: UI where the user uploads an image but leaves the description blank; clients assuming image-only (text-free) generation is supported; prompt extracted from the wrong field.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/b0ab12b8d2f9adf4. Report an issue: GitHub.