Skip to content

Supporting Vertex-based models using google auth #272

Closed

Description

@etrippler

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?

Activity

  1. self-assigned this
    on Jun 20, 2025
  2. NachoVazquez commented on Jun 22, 2025

    @NachoVazquez

    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.

  3. admSla99 commented on Jul 9, 2025

    @admSla99

    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.

  4. fredrikaverpil commented on Jul 22, 2025

    @fredrikaverpil

    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.

  5. NachoVazquez commented on Jul 22, 2025

    @NachoVazquez

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

  6. fredrikaverpil commented on Jul 22, 2025

    @fredrikaverpil

    @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.

  7. NachoVazquez commented on Jul 22, 2025

    @NachoVazquez

    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}"
          }
        }
      },
  8. NachoVazquez commented on Jul 22, 2025

    @NachoVazquez

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

  9. fredrikaverpil commented on Jul 22, 2025

    @fredrikaverpil

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

  10. NachoVazquez commented on Jul 22, 2025

    @NachoVazquez

    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.

    anomalyco/models.dev#23
    anomalyco/models.dev#60

  11. king-11 commented on Aug 15, 2025

    @king-11

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

  12. jacobmikesell commented on Aug 18, 2025

    @jacobmikesell

    Opened #2028 and confirmed its enough, theres probably a more elegant way, but it gets me off to the races for now!

  13. cafreeman commented on Aug 20, 2025

    @cafreeman

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

  14. jacobmikesell commented on Aug 22, 2025

    @jacobmikesell

    @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?

  15. rekram1-node commented on Aug 22, 2025

    @rekram1-node
    Contributor

    more to come on this v soon

  16. evatths commented on Aug 26, 2025

    @evatths

    This works now right?

      "provider": {
        "google-vertex": {
          "options": {
            "location": "us-west4",
            "project": "<project>"
          }
        },
    
  17. thdxr commented on Aug 27, 2025

    @thdxr
    Member

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

  18. chris-freeman-glean commented on Aug 27, 2025

    @chris-freeman-glean

    yessssssss can't wait

  19. bqrkhn commented on Aug 29, 2025

    @bqrkhn

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

  20. yukukotani commented on Sep 2, 2025

    @yukukotani
    Contributor

    opened PR #2347

  21. nefthy commented on Sep 5, 2025

    @nefthy

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

  22. cafreeman commented on Sep 10, 2025

    @cafreeman

    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

  23. rekram1-node commented on Sep 10, 2025

    @rekram1-node
    Contributor

    @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

  24. phase7 commented on Sep 18, 2025

    @phase7

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

  25. dan-myles commented on Sep 23, 2025

    @dan-myles

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

  26. jonnypillar-cio commented on Sep 25, 2025

    @jonnypillar-cio

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

  27. rawwerks commented on Oct 1, 2025

    @rawwerks

    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: #2347

  28. added a commit that references this issue on Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions