fix(workers-ai): fix broken multipart FormData examples for Flux models #27944
+40
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Responseconstructor workaround is neededProblem
The existing code examples for Flux 2 models (dev, klein-4b, klein-9b) don't work. They either:
formStream,formContentType)FormDatadirectly with a hardcoded"multipart/form-data"content-typeBoth approaches fail because the AI API requires the multipart boundary parameter in the
Content-Typeheader to parse the form fields.Solution
FormDatadoesn't expose its serialized body or boundary. Passing it to aResponse(orRequest) constructor serializes it and generates theContent-Typeheader with the boundary, which is required for the server to parse the multipart fields.Files Changed
src/components/models/code/Flux-2.astro- shared code example componentsrc/content/changelog/workers-ai/2026-01-15-flux-2-klein-4b-workers-ai.mdxsrc/content/changelog/workers-ai/2026-01-28-flux-2-klein-9b-workers-ai.mdxTesting
Verified all 3 models work with the fixed code:
@cf/black-forest-labs/flux-2-dev✓@cf/black-forest-labs/flux-2-klein-4b✓@cf/black-forest-labs/flux-2-klein-9b✓