autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Add support for Anthropic Claude models via Google Vertex AI

Open SrikarMannepalli opened this issue 2 months ago • 4 comments

Why are these changes needed?

This PR adds support for Anthropic Claude models via Google Vertex AI by introducing AnthropicVertexChatCompletionClient.

Background

While AutoGen already supports Anthropic Claude models through:

  • Direct API (AnthropicChatCompletionClient)
  • AWS Bedrock (AnthropicBedrockChatCompletionClient)

This PR add support for accessing Claude models through Vertex AI.

Changes Made

  1. New Client Class: AnthropicVertexChatCompletionClient following the same pattern as the existing Bedrock client
  2. Configuration Types: Added VertexInfo and related config models for GCP project/region configuration
  3. Tests: Added 11 comprehensive test cases covering initialization, serialization, config conversion, and mocked API calls
  4. Documentation: Added docstrings with usage examples and configuration loading patterns

Implementation Details

  • Uses Anthropic's official AsyncAnthropicVertex client
  • Requires project_id and region via VertexInfo configuration
  • Maintains consistency with existing AutoGen model client patterns
  • Supports all standard Claude model capabilities (vision, function calling, streaming)

Usage Example

from autogen_ext.models.anthropic import AnthropicVertexChatCompletionClient, VertexInfo

client = AnthropicVertexChatCompletionClient(
    model="claude-3-sonnet-20240229",
    vertex_info=VertexInfo(
        project_id="your-gcp-project-id",
        region="us-east5"
    )
)

Checks

SrikarMannepalli avatar Oct 27 '25 17:10 SrikarMannepalli

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 81.30%. Comparing base (13e144e) to head (dc93a88).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7097      +/-   ##
==========================================
+ Coverage   81.22%   81.30%   +0.07%     
==========================================
  Files         244      244              
  Lines       18512    18564      +52     
==========================================
+ Hits        15036    15093      +57     
+ Misses       3476     3471       -5     
Flag Coverage Δ
unittests 81.30% <100.00%> (+0.07%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Oct 27 '25 17:10 codecov[bot]

Hi @ekzhu, This change introduces support for Anthropic Claude models via Google Vertex AI along with tests. I kindly request you to review the PR whenever you get a chance. Please let me know if there are any additional adjustments or clarifications you’d like. Thanks so much for your time 🙏

SrikarMannepalli avatar Oct 27 '25 17:10 SrikarMannepalli

I analyzed this issue but couldn't identify the affected files. Could you please provide more details about which files need to be modified?

priteesshhh avatar Nov 09 '25 18:11 priteesshhh

I analyzed this issue but couldn't identify the affected files. Could you please provide more details about which files need to be modified?

This aims to add support for Anthropic Claude models via Google Vertex AI, and majorly affects the python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py file (in which a new class AnthropicVertexChatCompletionClient has been added) and its corresponding test.

SrikarMannepalli avatar Nov 10 '25 14:11 SrikarMannepalli