Skip to content

feat(ai): add VertexAI provider for Claude models - #1908

Merged
ksylvan merged 3 commits into
danielmiessler:mainfrom
rodaddy:feature/vertexai-provider
Dec 30, 2025
Merged

feat(ai): add VertexAI provider for Claude models#1908
ksylvan merged 3 commits into
danielmiessler:mainfrom
rodaddy:feature/vertexai-provider

Conversation

@rodaddy

@rodaddy rodaddy commented Dec 29, 2025

Copy link
Copy Markdown

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

  • Support for Claude models (Sonnet 4.5, Opus 4.5, Haiku 4.5, 3.7 Sonnet Latest, 3.5 Haiku Latest) via Vertex AI
  • Uses Google Application Default Credentials 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

Environment variables:

  • VERTEXAI_PROJECT_ID: GCP project ID (required)
  • VERTEXAI_REGION: Vertex AI region (optional, defaults to 'global')

Example .env configuration:

DEFAULT_VENDOR=VertexAI
DEFAULT_MODEL=claude-sonnet-4-5
VERTEXAI_PROJECT_ID=your-gcp-project
VERTEXAI_REGION=global

Testing

Tested with:

  • Claude Sonnet 4.5 model
  • Global endpoint (us-east5 also tested)
  • Both streaming and non-streaming requests
  • YouTube transcript processing

Related Issues

Closes #1570

Checklist

  • Follows contributing guidelines (small PR, conventional commits)
  • Implements complete ai.Vendor interface
  • Registered in plugin_registry.go
  • Tested with real-world usage
  • Changelog will be generated after PR number is assigned

rodaddy and others added 3 commits December 29, 2025 14:33
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
@ksylvan

ksylvan commented Dec 30, 2025

Copy link
Copy Markdown
Collaborator

@rodaddy Can you retest with the fixes/refactor I made to the PR?

@rodaddy

rodaddy commented Dec 30, 2025

Copy link
Copy Markdown
Author

@ksylvan Reviewed the refactoring - nice work on the toMessages extraction!

Verified:

  • ✅ Code compiles cleanly
  • ✅ Message conversion logic properly handles:
    • System message prepending to first user message
    • User/assistant role alternation enforcement
    • Empty message filtering
    • Edge cases (assistant-first, system-only scenarios)
  • ✅ Response handling iterates all content blocks (vs just first)

working on testing your code now

@rodaddy

rodaddy commented Dec 30, 2025

Copy link
Copy Markdown
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 toMessages refactor is a major improvement:

  • ✅ Proper system message handling (prepended to first user message)
  • ✅ User/assistant role alternation enforcement
  • ✅ Empty message filtering
  • ✅ Better response content block iteration
  • ✅ Improved error handling

The refactored implementation is solid and ready to merge from my perspective.

@ksylvan ksylvan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved @rodaddy - Thanks for the contribution!

@ksylvan
ksylvan merged commit baf5a2f into danielmiessler:main Dec 30, 2025
1 check passed
@rodaddy

rodaddy commented Dec 31, 2025

Copy link
Copy Markdown
Author

@ksylvan, will I get on the contributor list for this?

@ksylvan

ksylvan commented Dec 31, 2025

Copy link
Copy Markdown
Collaborator

Yes, @rodaddy - Happy New Year!

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.

[Feature request]: Vertex Support

2 participants