Skip to content

Support anthropic partner models #1134

@dhimmel

Description

@dhimmel

The docs imply that partner models (like those published by anthropic) are supported:

For the `model` parameter, supported formats for Vertex AI API include:
- The Gemini model ID, for example: 'gemini-2.0-flash'
- The full resource name starts with 'projects/', for example:
'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-2.0-flash'
- The partial resource name with 'publishers/', for example:
'publishers/google/models/gemini-2.0-flash' or
'publishers/meta/models/llama-3.1-405b-instruct-maas'
- `/` separated publisher and model name, for example:
'google/gemini-2.0-flash' or 'meta/llama-3.1-405b-instruct-maas'

However when I try claude sonnet 4 (model info):

from google import genai
client = genai.Client(
    vertexai=True, location='global'
)
response = client.models.generate_content(
    model='publishers/anthropic/models/claude-sonnet-4', contents="Respond with 'okay'."
)
print(response.text)

I get:

ClientError: 404 NOT_FOUND. {'error': {'code': 404, 'message': 'Publisher Model `projects/[project]/locations/global/publishers/anthropic/models/claude-sonnet-4` not found.', 'status': 'NOT_FOUND'}}

If I change location='us-east5' above, I get:

ClientError: 400 FAILED_PRECONDITION. {'error': {'code': 400, 'message': 'claude-sonnet-4 is not supported in the generateContent API.', 'status': 'FAILED_PRECONDITION'}}

Does this library intend to support partner models?

This occurred on SDK version 1.24.0

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions