Repository navigation
fix(vertex_ai): route xai/grok through completion adapter on generateContent - #42272
Rainmemery wants to merge 3 commits into
Conversation
…Content
POST /v1beta/models/{model}:generateContent treated vertex_ai/xai/grok-*
as a native Gemini model: get_provider_google_genai_generate_content_config()
only falls back to the litellm.completion() adapter for Vertex Partner
models, and PartnerModelPrefixes has no xai/ entry. Grok is dispatched to
VertexAIGoogleGenAIConfig and fails with a protocol mismatch.
xai/ publisher models are Model Garden OpenAI-compatible, matching how
get_vertex_ai_model_route() already serves them (MODEL_GARDEN). Route them
through the completion adapter on the unified Gemini-style endpoint, the
same way openai/gpt-oss-, moonshotai/, minimaxai/, etc. are handled.
Signed-off-by: Rainmemery <152621457+Rainmemery@users.noreply.github.com>
|
CI status: 88/92 check-runs green. The only failure is proxy-endpoints / Run tests, which dies at Save coverage report ? Failed to FinalizeArtifact: 403 Forbidden - the same GitHub Actions Node-20 / artifact-upload infra issue affecting several other contributor PRs (e.g. #42218, #42237); the test partition itself has no code-related annotations. All unit tests for the change pass locally under the CI configs (ruff.toml / ruff-tests.toml). |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Note on the codecov/patch 0% flag: the 2 'missing' lines are exactly the new branch in litellm/utils.py, and they are covered by the regression test added in this PR - but that coverage is reported missing because the proxy-endpoints / Run tests shard fails at its Save coverage report step with the same FinalizeArtifact: 403 infra error, so its coverage upload never lands. Verified locally with pytest-cov (the added lines do not appear in the missing list). Same repo-wide infra issue as #42263/#42218. |
|
Status update: CI is complete — 91/93 checks green. The only two failures are the known repo-level infra issues: |
Resolve the test_litellm/test_utils.py conflict by keeping both this PR's Vertex Grok generateContent test and main's new request-logging tests. litellm/utils.py auto-merged; the xai/ -> completion-adapter route is intact.
|
Hi maintainers 👋 — this PR is ready for a re-approve whenever you have a moment. Just merged latest The only red check is
The failure annotation is Happy to adjust anything — thanks for your time! 🙏 |
|
Thanks for this. #41836 fixes the same selector through get_vertex_ai_model_route, so we are merging that one and closing this as superseded |
|
Thanks for the update — happy to have this closed as superseded by #41836. I checked the diff: #41836 covers the same selector with the parametrized case ( |
TLDR
POST /v1beta/models/{model}:generateContent(the unified Gemini-style proxy endpoint) treatsvertex_ai/xai/grok-*as a native Gemini model and fails with a protocol mismatch, while/v1/chat/completionson the same deployment works fine.Root cause:
ProviderConfigManager.get_provider_google_genai_generate_content_config()only falls back to thelitellm.completion()adapter whenVertexAIPartnerModels.is_vertex_partner_model()is true, andPartnerModelPrefixeshas noxai/entry. Soxai/grok-*is handed toVertexAIGoogleGenAIConfig, which translates it as a Gemini call and the request breaks.Fix:
xai/publisher models are Model Garden OpenAI-compatible (seeget_vertex_ai_model_route()→MODEL_GARDEN). Route them through the completion adapter on the Gemini-style endpoint, the same wayopenai/gpt-oss-,moonshotai/,minimaxai/,zai-org/,google/gemma-are already handled.How it works
/v1beta/models/{model}:generateContentwithvertex_ai/xai/grok-*now returnsNonefromget_provider_google_genai_generate_content_config(), which makes thegenerate_contentsetup take the adapter path (GenerateContentToCompletionHandler) → translated into a chat-completions call →get_vertex_ai_model_route()dispatches to the Model Garden OpenAI-compatible handler.gemini-*models are unaffected (still getVertexAIGoogleGenAIConfig).Tests
test_get_provider_google_genai_generate_content_config_vertex_partner_modelsintests/test_litellm/test_utils.py— assertsxai/grok-*→None(adapter), partner models unchanged,gemini-1.5-pro→VertexAIGoogleGenAIConfig.