Commit 816a87f
feat: Support provider-prefixed Gemini model IDs
Merge #5555
## Summary
- Extract Gemini model names from LiteLLM-compatible provider-prefixed IDs such as `gemini/gemini-2.5-flash`, `vertex_ai/gemini-2.5-flash`, and `openrouter/google/gemini-2.5-pro:online`
- Keep malformed Vertex `projects/...` paths from being treated as valid Gemini IDs
- Add an OpenRouter-through-LiteLLM sample showing `OPENROUTER_API_KEY`, `api_base`, and `openrouter/...` model usage
## Why
ADK's Gemini tool checks already normalize native model IDs and Vertex/Apigee paths, but provider-prefixed LiteLLM model IDs were left as-is. That made Google Search reject routed Gemini IDs even when the underlying model name was Gemini. This updates the shared model-name utility so existing Gemini classification paths work for provider-prefixed IDs without special-casing one provider.
Refs #2709.
## Tests
- `uv run --extra test pytest tests/unittests/utils/test_model_name_utils.py tests/unittests/tools/test_google_search_tool.py`
- `uv run --extra dev pyink --check --diff --config pyproject.toml src/google/adk/utils/model_name_utils.py tests/unittests/utils/test_model_name_utils.py tests/unittests/tools/test_google_search_tool.py contributing/samples/hello_world_openrouter/agent.py contributing/samples/hello_world_openrouter/__init__.py`
- `uv run --extra test python -m py_compile contributing/samples/hello_world_openrouter/agent.py`
Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=#5555 from kenrogers:codex/provider-prefixed-gemini-models 60234b4
PiperOrigin-RevId: 9368894031 parent b3f278a commit 816a87f
3 files changed
Lines changed: 79 additions & 1 deletion
File tree
- src/google/adk/utils
- tests/unittests
- tools
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
253 | 274 | | |
254 | 275 | | |
255 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
71 | 85 | | |
72 | 86 | | |
73 | 87 | | |
| |||
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
123 | 144 | | |
124 | 145 | | |
125 | 146 | | |
| |||
172 | 193 | | |
173 | 194 | | |
174 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
175 | 203 | | |
176 | 204 | | |
177 | 205 | | |
| |||
223 | 251 | | |
224 | 252 | | |
225 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
226 | 267 | | |
227 | 268 | | |
228 | 269 | | |
| |||
253 | 294 | | |
254 | 295 | | |
255 | 296 | | |
| 297 | + | |
| 298 | + | |
256 | 299 | | |
257 | 300 | | |
258 | 301 | | |
| |||
0 commit comments