Skip to content

Register the bare model id 'claude-opus-5' to the Vertex AI route. - #758

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_967886387
Open

Register the bare model id 'claude-opus-5' to the Vertex AI route.#758
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_967886387

Conversation

@copybara-service

Copy link
Copy Markdown

Register the bare model id 'claude-opus-5' to the Vertex AI route.

WHY
lf.LanguageModel.get('claude-opus-5') returns the direct Anthropic API
client instead of the Vertex AI one. vertexai.py binds Anthropic models by
iterating anthropic.SUPPORTED_MODELS and registering only those entries
whose provider is 'VertexAI'. The Claude Opus 5 entry declares
provider='Anthropic', so that loop skips it and the bare id stays bound to
the direct-API class registered by anthropic.py. Callers that select a model
purely by bare id therefore get the wrong transport. The neighbouring
claude-opus-4-6 / 4-7 / 4-8 ids avoid this because each is listed in an
explicit override block; Claude Opus 5 was absent from that block.

WHAT
One line added to _register_vertexai_models():

lf.LanguageModel.register('claude-opus-5', VertexAIClaude5Opus)

HOW
The line extends the existing override block that encodes the convention
"bare model ids resolve as VertexAI (primary use case)".
VertexAIClaude5Opus is already defined in this module with
model = 'claude-opus-5'; it was declared but never registered, so no new
class, import, dependency or BUILD change is required.

Ordering is load-bearing: _register_vertexai_models() applies these explicit
overrides after the SUPPORTED_MODELS loops, so the override replaces the
earlier direct-API binding rather than being shadowed by it.

Only the bare id is registered. The sibling opus-4-x entries additionally pin
an '@latest' alias to the direct API; no such alias is defined for Opus 5, so
no corresponding line is added here.

WHY
`lf.LanguageModel.get('claude-opus-5')` returns the direct Anthropic API
client instead of the Vertex AI one. `vertexai.py` binds Anthropic models by
iterating `anthropic.SUPPORTED_MODELS` and registering only those entries
whose `provider` is 'VertexAI'. The Claude Opus 5 entry declares
`provider='Anthropic'`, so that loop skips it and the bare id stays bound to
the direct-API class registered by `anthropic.py`. Callers that select a model
purely by bare id therefore get the wrong transport. The neighbouring
claude-opus-4-6 / 4-7 / 4-8 ids avoid this because each is listed in an
explicit override block; Claude Opus 5 was absent from that block.

WHAT
One line added to `_register_vertexai_models()`:

  lf.LanguageModel.register('claude-opus-5', VertexAIClaude5Opus)

HOW
The line extends the existing override block that encodes the convention
"bare model ids resolve as VertexAI (primary use case)".
`VertexAIClaude5Opus` is already defined in this module with
`model = 'claude-opus-5'`; it was declared but never registered, so no new
class, import, dependency or BUILD change is required.

Ordering is load-bearing: `_register_vertexai_models()` applies these explicit
overrides after the `SUPPORTED_MODELS` loops, so the override replaces the
earlier direct-API binding rather than being shadowed by it.

Only the bare id is registered. The sibling opus-4-x entries additionally pin
an '@latest' alias to the direct API; no such alias is defined for Opus 5, so
no corresponding line is added here.

PiperOrigin-RevId: 967886387
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant