From 6f481ad0e36be3ccf15206c56c11862db7579ac0 Mon Sep 17 00:00:00 2001 From: Kan Wu Date: Wed, 9 Sep 2026 22:14:49 -0700 Subject: [PATCH] [router] Raise chat body cap to 32 MB for multimodal payloads (#38735) Co-authored-by: Claude Fable 5 --- experimental/sgl-router/src/server/routes/chat.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/experimental/sgl-router/src/server/routes/chat.rs b/experimental/sgl-router/src/server/routes/chat.rs index bf15ee8e4..ec311d0ce 100644 --- a/experimental/sgl-router/src/server/routes/chat.rs +++ b/experimental/sgl-router/src/server/routes/chat.rs @@ -107,14 +107,9 @@ fn prefill_policy_reason( } } -/// Per-route body-size cap on `/v1/chat/completions`. 5 MiB accommodates a -/// long context — a ~1 M-token context tokenized as JSON fits under this — -/// while preventing a hostile client from forcing the router to -/// heap-allocate hundreds of MiB before forwarding. The cap is wired in -/// `crate::server::app::build_router` as a route-level `DefaultBodyLimit` -/// layer; axum's `Bytes` extractor enforces it and returns 413 -/// PAYLOAD_TOO_LARGE before this handler runs. -pub const MAX_CHAT_BODY_BYTES: usize = 5 << 20; +/// Maximum buffered chat-completions body (32MiB). Sized for base64 multimodal inputs; +/// enforced by the `DefaultBodyLimit`, and returns 413 PAYLOAD_TOO_LARGE. +pub const MAX_CHAT_BODY_BYTES: usize = 32 << 20; /// Minimal probe over the request body — we only need the `stream` field /// and the `model` field to decide between buffered vs SSE forwarding and