danny-avila/LibreChat · error · Error
Invalid endpoint for finetuned generation. Must be one of: $
Error message
Invalid endpoint for finetuned generation. Must be one of: ${validFinetunedEndpoints.join(', ')} What it means
Third guard in generateFinetunedImage(): only two endpoints may be used for finetuned generation — '/v1/flux-pro-finetuned' and '/v1/flux-pro-1.1-ultra-finetuned'. If the caller-supplied `endpoint` is anything else, it is rejected before the HTTP call. The default (when endpoint is omitted) is '/v1/flux-pro-finetuned', which is valid, so this only fires when an explicit endpoint is supplied.
Source
Thrown at api/app/clients/tools/structured/FluxAPI.js:441
}
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,
output_format: imageData.output_format || 'png',
finetune_id: imageData.finetune_id,
finetune_strength: imageData.finetune_strength || 1.0,
guidance: imageData.guidance || 2.5,
};
// Add optional parameters if provided
if (imageData.width) {
payload.width = imageData.width;
}View on GitHub (pinned to 5ff282f900)
Solutions
- Omit `endpoint` to use the default '/v1/flux-pro-finetuned'.
- Set endpoint to exactly '/v1/flux-pro-finetuned' or '/v1/flux-pro-1.1-ultra-finetuned' (no trailing slash, exact case).
- If you genuinely need a new endpoint, add it to the validFinetunedEndpoints array in the source after confirming BFL/fal support it.
- Log the received endpoint value before the call to catch trailing-whitespace or encoding issues.
Example fix
// before
await fluxTool.invoke({
action: 'generate_finetuned',
prompt: 'a koi',
finetune_id: 'ft-1',
endpoint: '/v1/flux-pro', // not allowed for finetuned
});
// after
await fluxTool.invoke({
action: 'generate_finetuned',
prompt: 'a koi',
finetune_id: 'ft-1',
// endpoint omitted -> defaults to /v1/flux-pro-finetuned
}); Defensive patterns
Strategy: validation
Validate before calling
const FINETUNED_ENDPOINTS = ['/v1/flux-pro-finetuned', '/v1/flux-pro-1.1-ultra-finetuned'];
function buildFluxFinetunedArgs(input) {
const endpoint = input.endpoint || '/v1/flux-pro-finetuned';
if (!FINETUNED_ENDPOINTS.includes(endpoint)) {
throw new Error(`endpoint must be one of: ${FINETUNED_ENDPOINTS.join(', ')}`);
}
return { action: 'generate_finetuned', ...input, endpoint };
} Type guard
function isValidFinetunedEndpoint(arg) {
const ep = arg?.endpoint || '/v1/flux-pro-finetuned';
return ['/v1/flux-pro-finetuned', '/v1/flux-pro-1.1-ultra-finetuned'].includes(ep);
} Try / catch
try {
await fluxTool.invoke(args);
} catch (e) {
if (/Invalid endpoint for finetuned/.test(e.message)) return 'That endpoint does not support finetuned generation.';
throw e;
} Prevention
- Omit `endpoint` for finetuned runs unless you specifically need the ultra variant.
- Keep a single shared allowlist constant both in client validation and the tool source.
- Normalize endpoint strings (trim, lowercase path) before comparison.
When it happens
Trigger: Calling generate_finetuned with `imageData.endpoint` set to a value not in the allowlist — e.g. '/v1/flux-pro', '/v1/flux-dev', '/v1/flux-pro-1.1', or a typo like '/v1/flux-pro-finetuned/' (trailing slash).
Common situations: Caller reused a payload from a normal generate run (which uses '/v1/flux-pro'); attempted to point finetuned generation at a newer endpoint before adding it to the allowlist; trailing-slash or case mismatch; stale docs listing an old endpoint name.
Related errors
- Missing required field: finetune_id for finetuned generation
- 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/652a50bccdd19df3.
Report an issue: GitHub.