danny-avila/LibreChat · error · Error
Missing required field: prompt
Error message
Missing required field: prompt
What it means
Guard in FluxAPI._call() for the default `generate` action: after the list_finetunes and generate_finetuned branches are skipped, the remaining code path requires `imageData.prompt`. Distinct from the finetuned path which has its own prompt check (error 5).
Source
Thrown at api/app/clients/tools/structured/FluxAPI.js:210
async _call(data) {
const { action = 'generate', ...imageData } = data;
// Use provided API key for this request if available, otherwise use default
const requestApiKey = this.apiKey || this.getApiKey();
// Handle list_finetunes action
if (action === 'list_finetunes') {
return this.getMyFinetunes(requestApiKey);
}
// Handle finetuned generation
if (action === 'generate_finetuned') {
return this.generateFinetunedImage(imageData, requestApiKey);
}
// For generate action, ensure prompt is provided
if (!imageData.prompt) {
throw new Error('Missing required field: prompt');
}
let payload = {
prompt: imageData.prompt,
prompt_upsampling: imageData.prompt_upsampling || false,
safety_tolerance: imageData.safety_tolerance || 6,
output_format: imageData.output_format || 'png',
};
// Add optional parameters if provided
if (imageData.width) {
payload.width = imageData.width;
}
if (imageData.height) {
payload.height = imageData.height;
}
if (imageData.steps) {
payload.steps = imageData.steps;View on GitHub (pinned to 5ff282f900)
Solutions
- Supply a non-empty `prompt` string in the tool arguments for the generate action.
- Validate the payload before invoking the tool when prompt comes from user input.
- Re-check the tool's JSON schema so `prompt` is required and the model is steered to emit it.
- If the caller intended a finetuned run, set `action: 'generate_finetuned'` explicitly.
Example fix
// before
await fluxTool.invoke({ action: 'generate', width: 1024 });
// after
await fluxTool.invoke({ action: 'generate', prompt: 'a neon koi, cinematic', width: 1024 }); Defensive patterns
Strategy: validation
Validate before calling
function buildFluxGenerateArgs(input) {
if (typeof input.prompt !== 'string' || !input.prompt.trim()) {
throw new Error('FluxAPI generate requires a non-empty prompt.');
}
return { action: 'generate', ...input };
} Type guard
function hasPrompt(arg) {
return typeof arg?.prompt === 'string' && arg.prompt.trim().length > 0;
} Try / catch
try {
await fluxTool.invoke(args);
} catch (e) {
if (/Missing required field: prompt/.test(e.message)) return 'A prompt is required to generate.';
throw e;
} Prevention
- Require `prompt` in the FluxAPI schema for the generate action.
- Default `action` explicitly so an omitted prompt is caught early.
- Validate the arg shape at the tool-call boundary.
When it happens
Trigger: Calling the Flux tool with `action: 'generate'` (the default when action is omitted) and a payload whose `prompt` field is missing, null, undefined, or empty string.
Common situations: The model emitted tool args without a prompt (e.g., only width/height); a programmatic caller built the payload from optional user input that was empty; action defaulted to 'generate' when the caller intended a different action; schema mismatch between the tool description and what the model produced.
Related errors
- Missing required field: prompt
- Missing required field: prompt
- Missing required field: prompt
- Missing required field: finetune_id for finetuned generation
- Invalid endpoint for finetuned generation. Must be one of: $
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/81d7a8c71f0c4299.
Report an issue: GitHub.