danny-avila/LibreChat · error · Error
Missing required field: finetune_id for finetuned generation
Error message
Missing required field: finetune_id for finetuned generation. Please supply a finetune_id!
What it means
Second guard in generateFinetunedImage(): after prompt is present, a finetune_id is mandatory because the upstream /v1/flux-pro-finetuned endpoint rejects requests without it. The message is explicit about the missing field.
Source
Thrown at api/app/clients/tools/structured/FluxAPI.js:431
const formattedDetails = JSON.stringify(finetuneDetails, null, 2);
return [`Here are the available finetunes:\n${formattedDetails}`, null];
}
return JSON.stringify(finetuneDetails);
} catch (error) {
const details = this.getDetails(error?.response?.data || error.message);
logger.error('[FluxAPI] Error while getting finetunes:', details);
const errorMsg = `Failed to get finetunes: ${details}`;
return this.isAgent ? this.returnValue([errorMsg, {}]) : new Error(errorMsg);
}
}
async generateFinetunedImage(imageData, requestApiKey) {
if (!imageData.prompt) {
throw new Error('Missing required field: prompt');
}
if (!imageData.finetune_id) {
throw new Error(
'Missing required field: finetune_id for finetuned generation. Please supply a finetune_id!',
);
}
// Validate endpoint is appropriate for finetuned generation
const validFinetunedEndpoints = ['/v1/flux-pro-finetuned', '/v1/flux-pro-1.1-ultra-finetuned'];
const endpoint = imageData.endpoint || '/v1/flux-pro-finetuned';
if (!validFinetunedEndpoints.includes(endpoint)) {
throw new Error(
`Invalid endpoint for finetuned generation. Must be one of: ${validFinetunedEndpoints.join(', ')}`,
);
}
let payload = {
prompt: imageData.prompt,
prompt_upsampling: imageData.prompt_upsampling || false,
safety_tolerance: imageData.safety_tolerance || 6,View on GitHub (pinned to 5ff282f900)
Solutions
- Provide `finetune_id` (string) in the generate_finetuned payload.
- If unknown, first call `action: 'list_finetunes'` to enumerate available finetune IDs.
- Validate client-side that finetune_id is set before enabling the finetuned submit action.
- Make the tool schema require finetune_id for the finetuned action so the model is forced to supply it.
Example fix
// before
await fluxTool.invoke({
action: 'generate_finetuned',
prompt: 'a koi',
});
// after
await fluxTool.invoke({
action: 'generate_finetuned',
prompt: 'a koi',
finetune_id: 'flux-ft-20240101-abc',
}); Defensive patterns
Strategy: validation
Validate before calling
function buildFluxFinetunedArgs(input) {
if (typeof input.finetune_id !== 'string' || !input.finetune_id.trim()) {
throw new Error('generate_finetuned requires a finetune_id.');
}
return { action: 'generate_finetuned', ...input };
} Type guard
function hasFinetuneId(arg) {
return typeof arg?.finetune_id === 'string' && arg.finetune_id.trim().length > 0;
} Try / catch
try {
await fluxTool.invoke(args);
} catch (e) {
if (/Missing required field: finetune_id/.test(e.message)) return 'Select a finetune first.';
throw e;
} Prevention
- Require finetune_id in the schema for the generate_finetuned action.
- Offer a list_finetunes picker so the user always supplies a real ID.
- Validate finetune_id format (BFL/fal IDs have a known prefix) before calling.
When it happens
Trigger: Calling the Flux tool with `action: 'generate_finetuned'` and a valid `prompt`, but no `finetune_id` in imageData.
Common situations: The finetune ID was supposed to be selected from a list (list_finetunes) but the caller skipped that step; the ID lived in a variable that was undefined; copy/paste dropped the field; the model hallucinated a finetune call without the ID.
Related errors
- Invalid endpoint for finetuned generation. Must be one of: $
- Missing required field: prompt
- Missing required field: prompt
- Missing FLUX_API_KEY environment variable.
- Missing required field: prompt
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/03c52b745040918f.
Report an issue: GitHub.