BerriAI/litellm · error · BadRequestError

Vertex AI Search extra_body may not set target-selecting fie

Error message

Vertex AI Search extra_body may not set target-selecting fields {sorted(target_selecting)}: the data store is scoped by vector_store_id / vertex_engine_id and cannot be overridden per request.

What it means

Error "Vertex AI Search extra_body may not set target-selecting fields {sorted(target_selecting)}: the data store is scoped by vector_store_id / vertex_engine_id and cannot be overridden per request." thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/vertex_ai/vector_stores/search_api/transformation.py:95

    @classmethod
    def _filter_extra_body(cls, extra_body: dict[str, Any], is_engine: bool = False) -> dict[str, Any]:
        """
        Validate ``extra_body`` against the supported-field allowlist for the
        active serving config (engine/app vs data store).

        Raises ``BadRequestError`` (HTTP 400) if the caller includes a
        target-selecting field (e.g. ``servingConfig``) or any field not
        supported for the active mode, so the request fails loudly instead of
        silently searching the wrong target. Engine-only fields
        (``dataStoreSpecs``, ``numResultsPerDataStore``) are rejected in
        data-store mode where they are meaningless.
        """
        supported: Final = cls.get_supported_extra_body_fields(is_engine=is_engine)
        filtered: Final = {key: value for key, value in extra_body.items() if value is not None}

        target_selecting: Final = set(filtered) & VERTEX_SEARCH_TARGET_SELECTING_FIELDS
        if target_selecting:
            raise BadRequestError(
                message=(
                    "Vertex AI Search extra_body may not set target-selecting fields "
                    f"{sorted(target_selecting)}: the data store is scoped by "
                    "vector_store_id / vertex_engine_id and cannot be overridden per request."
                ),
                model="vertex_ai/search_api",
                llm_provider="vertex_ai",
            )

        unsupported: Final = set(filtered) - supported
        if unsupported:
            mode: Final = "engine/app" if is_engine else "data store"
            raise BadRequestError(
                message=(
                    f"Unsupported Vertex AI Search extra_body fields {sorted(unsupported)} "
                    f"for {mode} mode. Supported fields: {sorted(supported)}."
                ),
                model="vertex_ai/search_api",

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Remove the target-selecting fields (e.g. data_store_id, engine_id) listed in the error from extra_body.
  2. Set the data store scope once via vector_store_id / vertex_engine_id at configuration time instead of per request.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/vector_stores/search_api/transformation.py:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/e60d588b5ea4c214. Report an issue: GitHub.