How to Use Google Vertex AI in opencode
To use Google Vertex AI in opencode, connect Spiral to opencode once, then ask for what you want in plain words. opencode can then reach all 22 Google Vertex AI tools on Spiral, priced per run from one balance.
Prompts to try with Google Vertex AI in opencode
Copy an example into opencode, or ask in your own words.
Ask Google Vertex AI through Spiral to review the diff on this branch and list the three riskiest changes. Save the result in ./assets.
Get a second opinion from Google Vertex AI on this function, then tell me what the call cost.
Summarize these release notes with Google Vertex AI in five bullet points.
Ask Google Vertex AI to write unit tests for the file I have open and explain each case.
Compare Google Vertex AI with my current model on this prompt and tell me which answer is better and what each cost.
How to set up Google Vertex AI in opencode
Pick the way that suits you. Each takes about two minutes.
Use Spiral's MCP server
- Add the server
Leave out --global to add Spiral to the current project only. No header and no client ID or secret: opencode registers itself with Spiral.
opencode mcp add spiral --global --url https://api.spiral.ai/mcp
- Sign in
Your browser opens. Sign in to Spiral, pick the organization and click Authorize, then return to the terminal. No API key. Inside opencode, /mcps starts the same sign-in.
opencode mcp auth spiral
- Check it
Spiral shows as connected.
opencode mcp list
Use the Spiral skill
- Send opencode this message
Your agent reads Spiral's skill and sets itself up.
set up https://spiral.ai/SKILL.md
- Sign in or paste a key
Approve Spiral in the browser, or give the agent a key from the console.
Use the Spiral CLI
- Install and sign in
Installs the Spiral CLI, signs you in and adds its skill to your coding agents.
npx -y spiral-cli@latest init
Call the Spiral API
- Create an API key
In the console, under API keys.
- Run Google Vertex AI
One request; the result comes back by polling or a webhook.
curl https://api.spiral.ai/v1/runs \ -H "Authorization: Bearer $SPIRAL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "provider": "vertex", "model": "google/gemini-3.1-pro-preview", "input": { "messages": [ { "role": "system" } ] } }'
Then paste one of the prompts above: opencode finds Google Vertex AI on Spiral, shows the price and runs it.
Google Vertex AI tools you can run in opencode
3Ready to run from opencode: today's price, with every fee included.
Up to $0.063989 per run at the default inputs. $2.60 per 1M input tokens, $0.26 per 1M cached input tokens, $0.4875 per 1M cache write tokens, $15.60 per 1M output tokens; for a prompt above 200,000 tokens, $5.20 per 1M input tokens, $0.52 per 1M cached input tokens, $0.975 per 1M cache write tokens, $23.40 per 1M output tokens.
Up to $0.04806 per run at the default inputs. $1.95 per 1M input tokens, $0.195 per 1M cached input tokens, $0.108333335 per 1M cache write tokens, $3.90 per 1M audio input tokens, $11.70 per 1M output tokens.
About $1.788598 per run at the default inputs for 60 seconds of input. $15.60 per 1M video output tokens, $11.70 per 1M text output tokens, $1.95 per 1M input tokens.
What can you do with Google Vertex AI in opencode?
opencode can answer, write and review code with Google Vertex AI right in your repository and save the results where you need them: as files in your project, in a script or in your build. One sign-in covers every tool, so your code stays free of provider SDKs and keys.
Second opinions
Have another model review a diff or a plan before you commit to it.
Cheaper bulk work
Send summaries, tagging and rewrites to a smaller model and keep your agent's own model for hard steps.
Models your agent lacks
Reach open and frontier models your agent's vendor does not offer.
Code review at scale
Review every file in a pull request with one model and summarize the risks.
Long documents
Send a long spec or contract to a model with a large context window.
Structured output
Turn messy notes into JSON your code can read.
More on Google Vertex AI and opencode
Google Vertex AI in other agents
More opencode guides
Questions about Google Vertex AI in opencode
Can opencode use Google Vertex AI?
Yes. Add Spiral to opencode as an MCP server, and opencode can find and run Google Vertex AI like any built-in tool.
How much does Google Vertex AI cost in opencode?
Each tool has its own price, for example Gemini 3.1 Pro Preview: Up to $0.063989 per run at the default inputs. $2.60 per 1M input tokens, $0.26 per 1M cached input tokens, $0.4875 per 1M cache write tokens, $15.60 per 1M output tokens; for a prompt above 200,000 tokens, $5.20 per 1M input tokens, $0.52 per 1M cached input tokens, $0.975 per 1M cache write tokens, $23.40 per 1M output tokens; Gemini 3.5 Flash: Up to $0.04806 per run at the default inputs. $1.95 per 1M input tokens, $0.195 per 1M cached input tokens, $0.108333335 per 1M cache write tokens, $3.90 per 1M audio input tokens, $11.70 per 1M output tokens; Gemini Omni 1.2 Flash Video Generation: About $1.788598 per run at the default inputs for 60 seconds of input. $15.60 per 1M video output tokens, $11.70 per 1M text output tokens, $1.95 per 1M input tokens. You pay per run from one Spiral balance, and failed runs are free.
Do I need a Vertex AI account to use Google Vertex AI in opencode?
No. Spiral runs Google Vertex AI on its own Vertex AI account. You sign in to Spiral once and never paste a key.
How long does it take to set up Google Vertex AI in opencode?
About two minutes: add the server, then sign in, then check it.
Does opencode wait while Google Vertex AI runs?
Google Vertex AI runs in the background. opencode starts the run, checks on it and gives you the text, json when it's ready.
Why call Google Vertex AI from opencode?
For a second opinion, a cheaper model for bulk work, or a model your agent doesn't offer. Your agent calls Google Vertex AI through Spiral and pays only for the tokens used.
Which Google Vertex AI tools can opencode use?
opencode can reach all 22 Google Vertex AI tools on Spiral, covering LLM, image, video, and audio. Popular ones include Gemini 3.1 Pro Preview, Gemini 3.5 Flash, and Gemini Omni 1.2 Flash · Video Generation. Ask for one by name, or describe the task and opencode picks a fitting tool.
Can opencode compare Google Vertex AI tools?
Yes. Ask opencode to run the same request on two Google Vertex AI tools and show both results with what each cost. Each run is priced and billed on its own.
What happens if a Google Vertex AI run fails in opencode?
It is not charged. Spiral holds the estimated price when the run starts and returns it to your balance if the run fails on Spiral's side or the provider's. opencode gets the error and can retry or try another tool.
Is there a Google Vertex AI subscription or plan?
No. Spiral is pay as you go from one prepaid balance, with no plans or minimums, and credits never expire. Auto top-up keeps opencode from stopping when the balance runs low.
Start using Google Vertex AI in opencode
One Spiral account for every tool your agent needs. No subscription; you pay per run.
Paste this into opencode:
set up https://spiral.ai/SKILL.md


