feat(ai): add VertexAI provider for Claude models - #1908
Merged
Conversation
Add support for Google Cloud Vertex AI as a provider to access Claude models using Application Default Credentials (ADC). This allows users to route their Fabric requests through Google Cloud Platform instead of directly to Anthropic, enabling billing through GCP. Features: - Support for Claude models (Sonnet 4.5, Opus 4.5, Haiku 4.5, etc.) via Vertex AI - Uses Google ADC for authentication (no API keys required) - Configurable project ID and region (defaults to 'global' for cost optimization) - Full support for streaming and non-streaming requests - Implements complete ai.Vendor interface Configuration: - VERTEXAI_PROJECT_ID: GCP project ID (required) - VERTEXAI_REGION: Vertex AI region (optional, defaults to 'global') Closes danielmiessler#1570
…VertexAI client - Extract message conversion into dedicated `toMessages` helper method - Add proper role handling for system, user, and assistant messages - Prepend system content to first user message per Anthropic format - Enforce user/assistant message alternation with placeholder messages - Skip empty messages during conversion processing - Concatenate multiple text blocks in response output - Add validation for empty message arrays before sending - Handle edge case when only system content is provided
Collaborator
|
@rodaddy Can you retest with the fixes/refactor I made to the PR? |
Author
|
@ksylvan Reviewed the refactoring - nice work on the Verified:
working on testing your code now |
Author
|
@ksylvan Retested with the refactored code - works perfectly! ✅ Test Results: Non-streaming request: echo "Summarize quantum computing in one sentence" | fabric --model claude-sonnet-4-5 --vendor VertexAI✅ Response received successfully Streaming request: echo "Write a haiku about coffee" | fabric --model claude-sonnet-4-5 --vendor VertexAI --stream✅ Streaming works perfectly Code Quality:
The refactored implementation is solid and ready to merge from my perspective. |
Author
|
@ksylvan, will I get on the contributor list for this? |
Collaborator
|
Yes, @rodaddy - Happy New Year! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for Google Cloud Vertex AI as a provider to access Claude models using Application Default Credentials (ADC). This allows users to route their Fabric requests through Google Cloud Platform instead of directly to Anthropic, enabling billing through GCP.
Features
Configuration
Environment variables:
VERTEXAI_PROJECT_ID: GCP project ID (required)VERTEXAI_REGION: Vertex AI region (optional, defaults to 'global')Example .env configuration:
Testing
Tested with:
Related Issues
Closes #1570
Checklist