Backport of #51032 to lts/1.108.x as the prerequisite of #51279.
Cherry-picked from a0f2562088 (main).
Conflicts resolved: http_handler.py (the line has no _send_streaming_get, so only the anchor_handler_to rename was taken, including the line's own call site), tests/unit/batches/test_batch_utils.py and test_main.py (the line lacks the hosted_vllm batch tests the pick was formatted next to, so only the new gemini tests were taken). Line adaptation: join_api_base and _strip_trailing_slashes_keeping_the_scheme copied from main's url_utils (#47535) because the gemini files transformation needs them and the line never received that helper.
Line adaptation: the three join_api_base call sites validate GeminiModelInfo.get_api_base through TypeAdapter(str), because the line still annotates that helper as str | None while main returns str, so the type gate would otherwise count three new reportArgumentType errors.