feat: add openai-compatible endpoint support for google-vertex provider#10303
feat: add openai-compatible endpoint support for google-vertex provider#10303rekram1-node merged 18 commits intoanomalyco:devfrom
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.
according to google vertex docs, /v1beta1/ url path is for beta testing purpose. better to use /v1/ for stability.
Co-authored-by: BlueT - Matthew Lien - 練喆明 <BlueT@BlueT.org>
Thanks @bluet for the test and suggestion. I updated the url as you suggested. |
…ni in production while allowing custom proxies and localhost testing
|
Fixed the test failures and ensured compatibility with proxy servers. |
|
Is this ever going to be merged? |
I'm also waiting; I'm currently running my own local build just for this. lol |
|
same here +1! |
|
Would also appreciate this change! |
|
So this introduces a new "protocol" field which seems like it is used to set the npm package. But we already have fields to set the npm package any model can have it's own npm package setting regardless of the provider default |
|
I would also love this to get merged and new version with this released. It's blocking me from using Google Vertex API as well. |
Yep. we can use provider.npm instead. I removed Here is the example for a model: "google-vertex": {
"options": {
"project": "gcp-project-id",
"location": "global"
},
"models": {
"zai-org/glm-4.7-maas": {
"name": "GLM-4.7",
"provider": { "npm": "@ai-sdk/openai-compatible", "api": "" },
"limit": { "context": 204800, "output": 131072 },
"cost": { "input": 0.6, "output": 2.2 },
"interleaved": {
"field": "reasoning_content"
},
"attachment": false,
"reasoning": true,
"family": "glm",
"temperature": true,
"tool_call": true,
"modalities": {
"input": [ "text" ],
"output": [ "text" ]
},
"release_date": "2025-12-22",
}
}
}, |
|
@rekram1-node cleaned up the PR. removed all useless codes, mocks, tests and comments. rebased dev branch. Hope this is good now. |
|
merge train hype cho cho cho! thumbs up and thanks for this work! :) 🚂 |
|
This is also gonna be combined w/ changes in models.dev we will have things like this: Note that this is existing we just have to introduce this env var resolution pattern, and this ofc could be cleaned up a bit but the idea here is that models dont have to be tied to the provider base url, models can have their own package and own api = "base url" |
* dev: (1474 commits) fixing merge issue fix: google vertex var priority (anomalyco#13816) chore: generate feat: add openai-compatible endpoint support for google-vertex provider (anomalyco#10303) fix(desktop): normalize Linux Wayland/X11 backend and decoration policy (anomalyco#13143) feat(opencode): Add Venice support in temperature, topP, topK and smallOption (anomalyco#13553) desktop: use process-wrap instead of manual job object (anomalyco#13431) chore: generate fix(website): correct zh-CN translation of proprietary terms in zen.mdx (anomalyco#13734) feat(opencode): add `cljfmt` formatter support for Clojure files (anomalyco#13426) release: v1.2.5 feat(app): localize "free usage exceeded" error & "Add credits" clickable link (anomalyco#13652) fix(desktop): issue viewing new files opened from the file tree (anomalyco#13689) fix(app): only navigate prompt history at input boundaries (anomalyco#13690) fix(app): keybind [shift+tab] (anomalyco#13695) docs: add Ukrainian README translation (anomalyco#13697) fix(desktop): focus window after update/relaunch (anomalyco#13701) feat: Add GeistMono Nerd Font to available mono font options (anomalyco#13720) fix: ensure sqlite migration logs to stderr instead of stdout (anomalyco#13691) release: v1.2.4 ...
|
I am trying to use this in But getting the error:
Gemini methods under same google-vertex provider work fine (via the GOOGLE_APPLICATION_CREDENTIALS pointing to the service.account.json) I can manually try to do this which works: But I will have to manually refresh the key since gcloud apis are valid for 1 hour only. What am I missing? |
|
@NimaAra I haven't tested version 1.2.6 yet, but I have tested on the dev branch. I copy-pasted your configuration, and it worked. I suspect that you may not have properly logged in using |
|
@leehack Do you also use GOOGLE_APPLICATION_CREDENTIALS pointing to your |
|
@NimaAra For my configuration, I am not utilizing the JSON key. Instead, it should authenticate using the account I used when logging in with |
|
Got it, had to run Works great. Once again, thank you for the PR. |
|
Yes big thanks to @leehack this was a failure on our part. The google vertex ux through opencode is poor. We will improve. |
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