Supporting Vertex-based models using google auth #198

Closed
opened 2026-02-16 17:25:44 -05:00 by yindo · 26 comments
Owner

Originally created by @etrippler on GitHub (Jun 20, 2025).

Originally assigned to: @thdxr on GitHub.

Eg, something like:

{
  "$schema": "https://opencode.ai/config.json",
  "theme": "openai",
  "provider": {
    "vertexai": {
      "npm": "@ai-sdk/google-vertex",
      "options": {
        "project": "my-project-1",
        "location": "us-central1",
        "googleAuthOptions": {
          "keyFile": "creds.json"
        }
      },
      "models": {
        "gemini-2.5-pro": {},
        "gemini-2.0-flash": {},
        "gemini-2.5-flash": {},
        "claude-4.0-sonnet": {},
        "claude-4.0-opus": {}
      }
    }
  }
}

And actually this isn't fully accurate, @ai-sdk/google-vertex works for Gemini models but @ai-sdk/google-vertex/anthropic is needed for Claude models hosted on Vertex.

Alternatively, what I did for now is simply use my litellm proxy gateway running in a seperate process with the following config:

{
  "$schema": "https://opencode.ai/config.json",
  "theme": "openai",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://localhost:4000/v1",
        "apiKey": "sk-demo-1234"
      },
      "models": {
        "gemini-2.5-pro": {},
        "gemini-2.0-flash": {},
        "gemini-2.5-flash": {},
        "claude-4.0-sonnet": {},
        "claude-4.0-opus": {},
        "claude-3.7-sonnet": {},
        "o4-mini-high": {},
        "o4-mini": {},
        "o3": {}
      }
    }
  }
}

The only problem with this is you don't get token/cost tracking data. I think a fair number of people do this, so it could be nice to simply flag somehow that the model you're passing through is the "official" model from models.dev?

Originally created by @etrippler on GitHub (Jun 20, 2025). Originally assigned to: @thdxr on GitHub. Eg, something like: ``` { "$schema": "https://opencode.ai/config.json", "theme": "openai", "provider": { "vertexai": { "npm": "@ai-sdk/google-vertex", "options": { "project": "my-project-1", "location": "us-central1", "googleAuthOptions": { "keyFile": "creds.json" } }, "models": { "gemini-2.5-pro": {}, "gemini-2.0-flash": {}, "gemini-2.5-flash": {}, "claude-4.0-sonnet": {}, "claude-4.0-opus": {} } } } } ``` And actually this isn't fully accurate, `@ai-sdk/google-vertex` works for Gemini models but `@ai-sdk/google-vertex/anthropic` is needed for Claude models hosted on Vertex. Alternatively, what I did for now is simply use my `litellm` proxy gateway running in a seperate process with the following config: ``` { "$schema": "https://opencode.ai/config.json", "theme": "openai", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:4000/v1", "apiKey": "sk-demo-1234" }, "models": { "gemini-2.5-pro": {}, "gemini-2.0-flash": {}, "gemini-2.5-flash": {}, "claude-4.0-sonnet": {}, "claude-4.0-opus": {}, "claude-3.7-sonnet": {}, "o4-mini-high": {}, "o4-mini": {}, "o3": {} } } } } ``` The only problem with this is you don't get token/cost tracking data. I think a fair number of people do this, so it could be nice to simply flag somehow that the model you're passing through is the "official" model from `models.dev`?
yindo closed this issue 2026-02-16 17:25:44 -05:00
Author
Owner

@NachoVazquez commented on GitHub (Jun 22, 2025):

Oh yes, I need this, all my credits are in Vertex.

@thdxr, happy to help with the implementation. I won't jump into it right now, as you're assigned, but please let me know.

@NachoVazquez commented on GitHub (Jun 22, 2025): Oh yes, I need this, all my credits are in Vertex. @thdxr, happy to help with the implementation. I won't jump into it right now, as you're assigned, but please let me know.
Author
Owner

@admSla99 commented on GitHub (Jul 9, 2025):

I would also like to see Vertex AI support for Anthropic models. I believe most large companies already provide their employees access to LLMs through Vertex AI due to corporate policies. What is the current status of this feature? I look forward to helping with this.

@admSla99 commented on GitHub (Jul 9, 2025): I would also like to see Vertex AI support for Anthropic models. I believe most large companies already provide their employees access to LLMs through Vertex AI due to corporate policies. What is the current status of this feature? I look forward to helping with this.
Author
Owner

@fredrikaverpil commented on GitHub (Jul 22, 2025):

This worked for me, targeting a GCP project in Vertex AI (aiplatform.googleapis.com):

{
  "$schema": "https://opencode.ai/config.json",
  "theme": "system",
  "autoupdate": true,
  "provider": {
    "google-vertex": {
      "models": {
        "gemini-2.5-flash": {},
        "gemini-2.5-pro": {}
      },
      "options": {
        "project": "{env:GOOGLE_CLOUD_PROJECT}",
        "location": "{env:GOOGLE_CLOUD_LOCATION}"
      }
    }
  }
}

Authentication seems to be made under the hood by gcloud auth - or was it the fact that I ran opencode auth and gave it the access token from gclound auth application-default print-access-token? 🤷
I can see from cloud logs I'm making authenticated requests, so I can see that it really works.

@fredrikaverpil commented on GitHub (Jul 22, 2025): This worked for me, targeting a GCP project in Vertex AI (`aiplatform.googleapis.com`): ```json { "$schema": "https://opencode.ai/config.json", "theme": "system", "autoupdate": true, "provider": { "google-vertex": { "models": { "gemini-2.5-flash": {}, "gemini-2.5-pro": {} }, "options": { "project": "{env:GOOGLE_CLOUD_PROJECT}", "location": "{env:GOOGLE_CLOUD_LOCATION}" } } } } ``` Authentication seems to be made under the hood by `gcloud auth` - or was it the fact that I ran `opencode auth` and gave it the access token from `gclound auth application-default print-access-token`? 🤷 I can see from cloud logs I'm making authenticated requests, so I can see that it really works.
Author
Owner

@NachoVazquez commented on GitHub (Jul 22, 2025):

This is interesting, @fredrikaverpil. How would you define the model if you are using Claude through Vertex?

@NachoVazquez commented on GitHub (Jul 22, 2025): This is interesting, @fredrikaverpil. How would you define the model if you are using Claude through Vertex?
Author
Owner

@fredrikaverpil commented on GitHub (Jul 22, 2025):

@NachoVazquez not sure what you mean. I'm using gemini-cli and various Neovim plugins (codecompanion, avante) as well as opencode with the Gemini models in Vertex, namely flash 2.5 and pro 2.5. The models are specified in the snippet above.

@fredrikaverpil commented on GitHub (Jul 22, 2025): @NachoVazquez not sure what you mean. I'm using gemini-cli and various Neovim plugins (codecompanion, avante) as well as opencode with the Gemini models in Vertex, namely flash 2.5 and pro 2.5. The models are specified in the snippet above.
Author
Owner

@NachoVazquez commented on GitHub (Jul 22, 2025):

I'm trying to use Claude Code through Vertex. That's how I use it with Claude Code. I tried following your config, but it doesn't seem to work for me.

...
  "model": "vertex/claude-sonnet-4",
  "provider": {
    "vertex": {
      "models": {
        "claude-sonnet-4": {}
      },
      "options": {
        "project": "{env:GOOGLE_CLOUD_PROJECT}",
        "location": "{env:GOOGLE_CLOUD_LOCATION}"
      }
    }
  },
@NachoVazquez commented on GitHub (Jul 22, 2025): I'm trying to use Claude Code through Vertex. That's how I use it with Claude Code. I tried following your config, but it doesn't seem to work for me. ```json ... "model": "vertex/claude-sonnet-4", "provider": { "vertex": { "models": { "claude-sonnet-4": {} }, "options": { "project": "{env:GOOGLE_CLOUD_PROJECT}", "location": "{env:GOOGLE_CLOUD_LOCATION}" } } }, ```
Author
Owner

@NachoVazquez commented on GitHub (Jul 22, 2025):

Some development is needed, it seems, as stated in the issue description.

@NachoVazquez commented on GitHub (Jul 22, 2025): Some development is needed, it seems, as stated in the issue description.
Author
Owner

@fredrikaverpil commented on GitHub (Jul 22, 2025):

Claude is not listed under Vertex in https://models.dev, which is what opencode uses.

@fredrikaverpil commented on GitHub (Jul 22, 2025): Claude is not listed under Vertex in https://models.dev, which is what opencode uses.
Author
Owner

@NachoVazquez commented on GitHub (Jul 22, 2025):

Right, there are two PRs related to this, but it would probably not be enough since @ai-sdk/google-vertex is not enough; @ai-sdk/google-vertex/anthropic is needed here.

I will try to put a PR together this weekend.

https://github.com/sst/models.dev/pull/23
https://github.com/sst/models.dev/pull/60

@NachoVazquez commented on GitHub (Jul 22, 2025): Right, there are two PRs related to this, but it would probably not be enough since `@ai-sdk/google-vertex` is not enough; ` @ai-sdk/google-vertex/anthropic` is needed here. I will try to put a PR together this weekend. https://github.com/sst/models.dev/pull/23 https://github.com/sst/models.dev/pull/60
Author
Owner

@king-11 commented on GitHub (Aug 15, 2025):

Both the PRs are merged I think we can work on bringing the anthropic SDK into opencode?

@king-11 commented on GitHub (Aug 15, 2025): Both the PRs are merged I think we can work on bringing the anthropic SDK into opencode?
Author
Owner

@jacobmikesell commented on GitHub (Aug 17, 2025):

Opened https://github.com/sst/opencode/pull/2028 and confirmed its enough, theres probably a more elegant way, but it gets me off to the races for now!

@jacobmikesell commented on GitHub (Aug 17, 2025): Opened https://github.com/sst/opencode/pull/2028 and confirmed its enough, theres probably a more elegant way, but it gets me off to the races for now!
Author
Owner

@cafreeman commented on GitHub (Aug 20, 2025):

Any updates on this PR? I think this is the only thing between me and being able to use opencode at work 🤞

@cafreeman commented on GitHub (Aug 20, 2025): Any updates on this PR? I think this is the only thing between me and being able to use opencode at work 🤞
Author
Owner

@jacobmikesell commented on GitHub (Aug 22, 2025):

@thdxr is this something that qualifies for open source contribution (I'm unsure what the line is for "core features") and/or would you be able to take a look?

@jacobmikesell commented on GitHub (Aug 22, 2025): @thdxr is this something that qualifies for open source contribution (I'm unsure what the line is for "core features") and/or would you be able to take a look?
Author
Owner

@rekram1-node commented on GitHub (Aug 22, 2025):

more to come on this v soon

@rekram1-node commented on GitHub (Aug 22, 2025): more to come on this v soon
Author
Owner

@evatt-harvey-salinger commented on GitHub (Aug 26, 2025):

This works now right?

  "provider": {
    "google-vertex": {
      "options": {
        "location": "us-west4",
        "project": "<project>"
      }
    },
@evatt-harvey-salinger commented on GitHub (Aug 26, 2025): This works now right? ``` "provider": { "google-vertex": { "options": { "location": "us-west4", "project": "<project>" } }, ```
Author
Owner

@thdxr commented on GitHub (Aug 27, 2025):

ill fix this this week, we're getting setup on vertex ourselves

@thdxr commented on GitHub (Aug 27, 2025): ill fix this this week, we're getting setup on vertex ourselves
Author
Owner

@chris-freeman-glean commented on GitHub (Aug 27, 2025):

yessssssss can't wait

@chris-freeman-glean commented on GitHub (Aug 27, 2025): yessssssss can't wait
Author
Owner

@bqrkhn commented on GitHub (Aug 29, 2025):

Can't wait. Google gave us credits and fire up Opus with OpenCode

@bqrkhn commented on GitHub (Aug 29, 2025): Can't wait. Google gave us credits and fire up Opus with OpenCode
Author
Owner

@yukukotani commented on GitHub (Sep 2, 2025):

opened PR https://github.com/sst/opencode/pull/2347

@yukukotani commented on GitHub (Sep 2, 2025): opened PR https://github.com/sst/opencode/pull/2347
Author
Owner

@nefthy commented on GitHub (Sep 5, 2025):

@bqrkhn can't use your credits with anthropic models.

@nefthy commented on GitHub (Sep 5, 2025): @bqrkhn can't use your credits with anthropic models.
Author
Owner

@cafreeman commented on GitHub (Sep 10, 2025):

Any updates on this? There's been a couple minor version updates and I keep hoping one of them will make my vertex stuff start working

@cafreeman commented on GitHub (Sep 10, 2025): Any updates on this? There's been a couple minor version updates and I keep hoping one of them will make my vertex stuff start working
Author
Owner

@rekram1-node commented on GitHub (Sep 10, 2025):

@thdxr said they are working on it, they actually will be using vertex for a bunch of their work internally so I expect the vertex support to be really good once it is here

@rekram1-node commented on GitHub (Sep 10, 2025): @thdxr said they are working on it, they actually will be using vertex for a bunch of their work internally so I expect the vertex support to be really good once it is here
Author
Owner

@phase7 commented on GitHub (Sep 18, 2025):

Would love to see this work, I believe this will help opencode's adoption soar higher

@phase7 commented on GitHub (Sep 18, 2025): Would love to see this work, I believe this will help opencode's adoption soar higher
Author
Owner

@dan-myles commented on GitHub (Sep 23, 2025):

Would love seeing this, their TPS is off the charts.

@dan-myles commented on GitHub (Sep 23, 2025): Would love seeing this, their TPS is off the charts.
Author
Owner

@jonnypillar-cio commented on GitHub (Sep 25, 2025):

I check this daily in the hope I can finally use this at work 😢

@jonnypillar-cio commented on GitHub (Sep 25, 2025): I check this daily in the hope I can finally use this at work 😢
Author
Owner

@rawwerks commented on GitHub (Oct 1, 2025):

i am sitting on $100K in gcp credits and a super high vertex rate limit, would love to experiment with opencode if we could get this through: https://github.com/sst/opencode/pull/2347

@rawwerks commented on GitHub (Oct 1, 2025): i am sitting on $100K in gcp credits and a super high vertex rate limit, would love to experiment with opencode if we could get this through: https://github.com/sst/opencode/pull/2347
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#198