Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

routes: fix embed 413 vs 400 routing (#18822)

Patrick Devine0d0720e51fb2
diff --git a/server/routes.go b/server/routes.go
index 501d04d06..90ed6789a 100644
--- a/server/routes.go
+++ b/server/routes.go
@@ -1278,8 +1278,15 @@ func (s *Server) EmbedHandler(c *gin.Context) {
return nil, 0, terr
}
if !ok {
- // Nothing to truncate (e.g. the text fits but media expansion
- // overflowed the runner): the original 413 stands.
+ // Nothing to truncate. For plain text that means the runner
+ // rejected input the server-side limit accepted (e.g. a
+ // physical-batch clamp), so keep the truncation-family error the
+ // API contract encodes. For media items the overflow came from
+ // media expansion past the text the truncator sees, so the
+ // runner's 413 is the honest error.
+ if len(item.media) == 0 {
+ return nil, 0, fmt.Errorf("input exceeds maximum context length and cannot be truncated further")
+ }
return nil, 0, err
}