Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
👔 fix: Route Flux Finetuned Endpoints Regardless of Action (#15336)
Ayush Verma64258372699a
diff --git a/api/app/clients/tools/structured/FluxAPI.js b/api/app/clients/tools/structured/FluxAPI.jsindex fd0464c34e..c3ed8d2fcf 100644--- a/api/app/clients/tools/structured/FluxAPI.js+++ b/api/app/clients/tools/structured/FluxAPI.js@@ -91,6 +91,9 @@ const fluxApiJsonSchema = {const displayMessage ="Flux displayed an image. All generated images are already plainly visible, so don't repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user.";+/** Endpoints that require a `finetune_id`, regardless of which `action` the caller selected. */+const FINETUNED_ENDPOINTS = ['/v1/flux-pro-finetuned', '/v1/flux-pro-1.1-ultra-finetuned'];+/*** FluxAPI - A tool for generating high-quality images from text prompts using the Flux API.* Each call generates one image. If multiple images are needed, make multiple consecutive calls with the same or varied prompts.@@ -200,8 +203,9 @@ class FluxAPI extends Tool {return this.getMyFinetunes(requestApiKey);}- // Handle finetuned generation- if (action === 'generate_finetuned') {+ // Handle finetuned generation. Route by endpoint too, since a finetuned+ // endpoint requires finetune_id regardless of which action was selected.+ if (action === 'generate_finetuned' || FINETUNED_ENDPOINTS.includes(imageData.endpoint)) {return this.generateFinetunedImage(imageData, requestApiKey);}@@ -434,12 +438,11 @@ class FluxAPI extends Tool {}// 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)) {+ if (!FINETUNED_ENDPOINTS.includes(endpoint)) {throw new Error(- `Invalid endpoint for finetuned generation. Must be one of: ${validFinetunedEndpoints.join(', ')}`,+ `Invalid endpoint for finetuned generation. Must be one of: ${FINETUNED_ENDPOINTS.join(', ')}`,);}diff --git a/api/app/clients/tools/structured/specs/imageTools-agent.spec.js b/api/app/clients/tools/structured/specs/imageTools-agent.spec.jsindex 2d36ad4b7f..c27e73725d 100644--- a/api/app/clients/tools/structured/specs/imageTools-agent.spec.js+++ b/api/app/clients/tools/structured/specs/imageTools-agent.spec.js@@ -338,6 +338,51 @@ describe('image tools - agent mode ToolMessage format', () => {expect(contentStr).toContain('Something went wrong');expect(result.artifact).toBeDefined();});++ it('routes a finetuned endpoint through generateFinetunedImage even when action is left as "generate"', async () => {+ const flux = new FluxAPI({ isAgent: true });+ const invokePromise = flux.invoke(+ makeToolCall('flux', {+ prompt: 'a box',+ endpoint: '/v1/flux-pro-finetuned',+ finetune_id: 'ft-abc123',+ finetune_strength: 0.8,+ guidance: 3,+ }),+ );+ await jest.runAllTimersAsync();+ const result = await invokePromise;++ expect(axios.post).toHaveBeenCalledWith(+ expect.stringContaining('/v1/flux-pro-finetuned'),+ expect.objectContaining({+ finetune_id: 'ft-abc123',+ finetune_strength: 0.8,+ guidance: 3,+ }),+ expect.anything(),+ );++ expect(result).toBeInstanceOf(ToolMessage);+ expect(result.artifact).toBeDefined();+ const artifactContent = result.artifact?.content;+ expect(Array.isArray(artifactContent)).toBe(true);+ expect(artifactContent[0].type).toBe(ContentTypes.IMAGE_URL);+ expect(artifactContent[0].image_url.url).toContain('base64');+ });++ it('rejects a finetuned endpoint without finetune_id even when action is left as "generate"', async () => {+ const flux = new FluxAPI({ isAgent: true });++ await expect(+ flux.invoke(+ makeToolCall('flux', {+ prompt: 'a box',+ endpoint: '/v1/flux-pro-finetuned',+ }),+ ),+ ).rejects.toThrow(/finetune_id/);+ });});describe('StableDiffusion', () => {