-
Notifications
You must be signed in to change notification settings - Fork 9k
feat: add google-vertex-openapi provider with ADC authentication #10303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
The other Google Vertex-related PRs (#9568, #6860, #5422, #5166) appear to be focused on different aspects (model resolution, token stats, cache configuration, naming conventions) rather than authentication implementation. |
377d80e to
5aba6e0
Compare
|
Can we get this merged please? |
|
Hey @leehack, great work on this! I was working on a similar solution (now closed #10742) and your approach of extending the existing google-vertex provider with I've also been coordinating with @rekram1-node on models.dev PR #716 for the model definitions. He mentioned consolidating all google-vertex models under a single provider, which aligns perfectly with your implementation here. Happy to help test this PR if needed - I have a GCP project with GLM-4.7 access via Vertex AI Model Garden. One small observation: The baseURL uses |
Awesome! |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
Test Results: v1 vs v1beta1 EndpointsI tested both API versions with GLM-4.7. Both work! Results
ConclusionYour current implementation using The correct model ID format is Documentation Reference
|
Follow-up: Recommendation to use
|
| Aspect | /v1/ (Stable) |
/v1beta1/ (Beta) |
|---|---|---|
| SLA | ✅ Covered | ❌ No guarantees |
| Breaking Changes | ❌ Not allowed | |
| Deprecation Notice | Min 1 year | ~180 days (not guaranteed) |
| Production Use | ✅ Recommended |
Reference: Google's Official Policy
From AIP-181 and Google Cloud Launch Stages:
- Beta: No SLAs or technical support obligations unless specified
- Stable (v1): Fully-supported, covered by SLA, no breaking changes
Suggested Change
In the loader's baseURL construction:
- `https://${location}-aiplatform.googleapis.com/v1beta1/projects/...`
+ `https://${location}-aiplatform.googleapis.com/v1/projects/...`Both work identically for the OpenAPI-compatible endpoint (I tested both), but /v1/ provides stronger stability guarantees for production use.
bluet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to google vertex docs, /v1beta1/ url path is for beta testing purpose. better to use /v1/ for stability.
| location, | ||
| baseURL: | ||
| location === "global" | ||
| ? `https://aiplatform.googleapis.com/v1beta1/projects/${project}/locations/${location}/endpoints/openapi` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ? `https://aiplatform.googleapis.com/v1beta1/projects/${project}/locations/${location}/endpoints/openapi` | |
| ? `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi` |
| baseURL: | ||
| location === "global" | ||
| ? `https://aiplatform.googleapis.com/v1beta1/projects/${project}/locations/${location}/endpoints/openapi` | ||
| : `https://${location}-aiplatform.googleapis.com/v1beta1/projects/${project}/locations/${location}/endpoints/openapi`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| : `https://${location}-aiplatform.googleapis.com/v1beta1/projects/${project}/locations/${location}/endpoints/openapi`, | |
| : `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`, |
Summary
Adds a new
google-vertex-openapiprovider that enables using third-party models (like GLM-4.7) on Google Vertex AI through the OpenAPI-compatible endpoint.Fixes #10304
Changes
Provider Implementation (
src/provider/provider.ts):google-auth-librarygetModelfunction for consistency with other providersTest Infrastructure (
test/provider/provider.test.ts):Mocked
google-auth-libraryfor testing supportConfiguration:
GOOGLE_CLOUD_PROJECT,GCP_PROJECT,GCLOUD_PROJECT(project)GOOGLE_CLOUD_LOCATION,VERTEX_LOCATION(location)provider.options.project,provider.options.locationAuthentication:
gcloud auth application-default login(easiest for development)GOOGLE_APPLICATION_CREDENTIALSfor service accounts (production)Verification
Usage
{ "provider": { "google-vertex-openapi": { "name": "Google Vertex AI (OpenAPI)", "npm": "@ai-sdk/openai-compatible", "api": "https://aiplatform.googleapis.com/v1beta1", "options": { "project": "my-project-id", "location": "global" }, "models": { "glm-4.7": { "name": "GLM-4.7", "tool_call": true, "reasoning": true, "limit": {"context": 128000, "output": 8192} } } } } }Setup