Skip to content

Commit 75ec567

Browse files
committed
refactor(router): consolidate model field into VERTEX_INCOMPATIBLE_BODY_FIELDS
Move the standalone obj.remove("model") into the shared stripping array so all Vertex AI rawPredict body-field removals are handled in one place, per reviewer feedback.
1 parent 2619030 commit 75ec567

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

crates/openshell-router/src/backend.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ const VERTEX_ANTHROPIC_VERSION: &str = "vertex-2023-10-16";
8686
/// Add new fields here as Claude Code and other Anthropic SDK clients
8787
/// introduce new extension-only body fields.
8888
const VERTEX_INCOMPATIBLE_BODY_FIELDS: &[&str] = &[
89+
// Vertex AI rawPredict encodes the model in the URL path, not the request body.
90+
// Clients using the standard Anthropic API always send "model" in the body; strip it.
91+
"model",
8992
// Claude Code 2.1.x context management feature (USE_API_CONTEXT_MANAGEMENT).
9093
// Disabled in clients by CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1.
9194
// Vertex AI schema does not include this field; it causes HTTP 400.
@@ -293,13 +296,7 @@ fn prepare_backend_request(
293296
// Anthropic publisher endpoints, not for arbitrary model-in-path routes.
294297
let needs_vertex_anthropic_version = is_vertex_anthropic_rawpredict_route(route);
295298
if needs_vertex_anthropic_version {
296-
// Vertex AI rawPredict encodes the model in the URL path, not
297-
// the request body. Clients using the standard Anthropic API
298-
// (e.g. Claude Code via inference.local) always send "model"
299-
// in the body; strip it so Vertex AI does not reject the
300-
// request with "Extra inputs are not permitted".
301-
obj.remove("model");
302-
// Strip Anthropic SDK extension body fields not supported by Vertex AI rawPredict.
299+
// Strip body fields not supported by Vertex AI rawPredict.
303300
// Vertex AI schema-validates the request body and rejects unknown fields with
304301
// HTTP 400 "Extra inputs are not permitted". Header-level betas are already
305302
// stripped above (`strip_anthropic_beta`); this handles the body-field equivalent.

0 commit comments

Comments
 (0)