Skip to content

feat: support injecting custom LLM clients into Gemini and AnthropicLlm - #5035

Closed
brucearctor wants to merge 6 commits into
google:mainfrom
brucearctor:feature/5027-custom-client
Closed

brucearctor wants to merge 6 commits into
google:mainfrom
brucearctor:feature/5027-custom-client

Conversation

@brucearctor

@brucearctor brucearctor commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

Enable injecting pre-configured LLM clients into Gemini and AnthropicLlm models to support multi-agent systems with distinct configurations. Addresses #5027.

Testing Plan

I have verified these changes with the following:

Automated Tests

  • New Unit Tests: Added which specifically mocks the and clients to verify they are correctly consumed by the cached properties.
  • Regression Testing: Ran all 86 existing unit tests in and to ensure legacy behavior via environment variables is preserved.

Manual Verification

  • Pydantic Validation: Verified model initialization with actual and objects to ensure no runtime Pydantic resolution errors ().

Verification Command

uv run pytest tests/unittests/models/test_custom_client.py
uv run pytest tests/unittests/models/test_google_llm.py tests/unittests/models/test_anthropic_llm.py

@adk-bot

adk-bot commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

Response from ADK Triaging Agent

Hello @brucearctor, thank you for your contribution!

To help reviewers better understand and verify your changes, could you please add a testing plan section to your PR description? This should describe how you've tested the changes, including any manual end-to-end tests you've performed.

You can find more details in our contribution guidelines.

Thanks!

@adk-bot adk-bot added the models [Component] This issue is related to model support label Mar 28, 2026
@rohityan rohityan self-assigned this Mar 30, 2026
Comment thread src/google/adk/models/google_llm.py
Comment thread src/google/adk/models/google_llm.py Outdated
Comment thread src/google/adk/models/google_llm.py Outdated
Comment thread src/google/adk/models/apigee_llm.py
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Mar 30, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @brucearctor , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
Please address the review comments.

@brucearctor

Copy link
Copy Markdown
Contributor Author

Hi @brucearctor , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please address the review comments.

looking into them

- Move Client import to TYPE_CHECKING, remove duplicate top-level import
- Exclude client field from Pydantic serialization using Field(exclude=True)
- Apply custom client guard to _live_api_client for consistency
- Add client parameter to ApigeeLlm.__init__ and forward to super()
@brucearctor

Copy link
Copy Markdown
Contributor Author

I think got these comments addressed. While I hate using Any type, to address your comments/suggestions, I failed to find a workaround.

@naresh-gn

Copy link
Copy Markdown

@rohityan any update on this PR?

eoinfennessy pushed a commit to eoinfennessy/llama-stack that referenced this pull request Apr 30, 2026
…tatus (ogx-ai#5667)

# What does this PR do?

Update Google Interactions API documentation to reflect the current
state after tool calling support merged in ogx-ai#5572. Document the Google
ADK limitation where its `Gemini` class cannot accept a custom
`genai.Client` with a custom `base_url`, linking to the upstream PR
google/adk-python#5035 with workarounds. Fix code examples to use the
proper `http_options` API instead of the private `_api_client._url`
hack.

## Test Plan

Documentation-only change, no code modified. Verified markdown renders
correctly by reviewing the raw files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Sébastien Han <seb@redhat.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
copybara-service Bot pushed a commit that referenced this pull request Aug 21, 2026
Merge #5035

Enable injecting pre-configured LLM clients into Gemini and AnthropicLlm models to support multi-agent systems with distinct configurations.

Fixes #5027

PiperOrigin-RevId: 968151995
@adk-bot

adk-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Thank you @brucearctor for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit a01d516.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Aug 21, 2026
@adk-bot adk-bot closed this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged models [Component] This issue is related to model support request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants