danny-avila/LibreChat · error · Error

Missing required field: prompt

Error message

Missing required field: prompt

What it means

Runtime guard inside DALLE3._call(): the tool input must contain a `prompt` string before it will call OpenAI's images.generate. Thrown synchronously before any network request, so it is a caller/agent error, not an OpenAI-side failure.

Source

Thrown at api/app/clients/tools/structured/DALLE3.js:155

  wrapInMarkdown(imageUrl) {
    return `![generated image](${imageUrl})`;
  }

  returnValue(value) {
    if (this.isAgent === true && typeof value === 'string') {
      return [value, {}];
    } else if (this.isAgent === true && typeof value === 'object') {
      return [displayMessage, value];
    }

    return value;
  }

  async _call(data) {
    const { prompt, quality = 'standard', size = '1024x1024', style = 'vivid' } = data;
    if (!prompt) {
      throw new Error('Missing required field: prompt');
    }

    let resp;
    try {
      resp = await this.openai.images.generate({
        model: 'dall-e-3',
        quality,
        style,
        size,
        prompt: this.replaceUnwantedChars(prompt),
        n: 1,
      });
    } catch (error) {
      logger.error('[DALL-E-3] Problem generating the image:', error);
      return this
        .returnValue(`Something went wrong when trying to generate the image. The DALL-E API may be unavailable:
Error Message: ${error.message}`);
    }

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Ensure the tool-call arguments include a non-empty `prompt` string before invocation.
  2. Align the tool's JSON schema and the system prompt so the model emits `prompt` as the argument name.
  3. If invoking programmatically, validate the payload shape before calling _call().
  4. Sanitize the prompt upstream so whitespace-only strings are rejected before they reach the tool.

Example fix

// before
await dalleTool.invoke({ description: 'a red fox' }); // wrong key

// after
await dalleTool.invoke({ prompt: 'a red fox in snow, vivid' });
Defensive patterns

Strategy: validation

Validate before calling

function buildDalleArgs(input) {
  if (typeof input.prompt !== 'string' || input.prompt.trim() === '') {
    throw new Error('DALLE3 requires a non-empty prompt string.');
  }
  return { prompt: input.prompt, quality: input.quality, size: input.size, style: input.style };
}

Type guard

function hasPrompt(arg) {
  return typeof arg?.prompt === 'string' && arg.prompt.trim().length > 0;
}

Try / catch

try {
  await dalleTool.invoke(args);
} catch (e) {
  if (/Missing required field: prompt/.test(e.message)) {
    return 'Please provide a description for the image.';
  }
  throw e;
}

Prevention

When it happens

Trigger: The agent/model invokes the DALLE3 tool with a JSON payload that omits `prompt`, passes prompt: null/undefined, or passes an object that destructures to a falsy prompt value.

Common situations: LLM tool-call emitted arguments in the wrong shape (e.g., {description: ...} instead of {prompt: ...}); a schema change to the tool that the model's cached instructions do not reflect; manual programmatic invocation that forgot the field; prompt coerced to empty string upstream by replaceUnwantedChars on whitespace-only input.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/c3745cd151d52db6. Report an issue: GitHub.