Docs · Guide

Google Vertex AI in Claude Code, Codex and other agents

Google Vertex AI, which Google's documentation now calls Gemini Enterprise Agent Platform, serves Gemini from your own Google Cloud project, which is billed for it. It also serves partner and open models such as DeepSeek, GLM and gpt-oss, and Anthropic's Claude. magpie's google-vertex preset brings them to Claude Code, Codex, OpenCode and other agents with no API key: each request is signed with a token minted from your Google credentials.

Add it

  1. Turn on the API.Turn on the Agent Platform API (aiplatform.googleapis.com) in the project. Billing has to be on there.
  2. Sign in.Run gcloud auth application-default login, or have a service account's key file.
  3. Add and test.Give the project id, then test:
Terminal
gcloud auth application-default login
magpie provider add google-vertex project=my-project
magpie provider test google-vertex

The app's editor asks the same in Project ID, Location, Credentials file and Service account. The TUI's a asks for the project alone, and the CLI sets the rest. Adding, listing and showing it ask Google nothing; the credentials are read when a request is signed. Then pick a model for an agent:

Terminal
magpie claude google-vertex/claude-sonnet-5-5
magpie codex google-vertex/gemini-3.1-pro-preview

Location, credentials, service account

Terminal
magpie provider set google-vertex location=us-central1        # global (default), us, eu or a region
magpie provider set google-vertex credentials=~/keys/vertex.json
magpie provider set google-vertex impersonate=vertex@my-project.iam.gserviceaccount.com
magpie provider set google-vertex impersonate=                # empty clears it

Models per location

Each location serves models of its own, and Vertex AI has no list to ask which, so magpie gives each location the models it answered with:

When a region serves one more, as asia-northeast1 serves gemini-3.5-flash, type it in with the rest you want. Moving location keeps the models picked, so pick again after a move.

Partner models

A partner model names its publisher before a slash, as deepseek-ai/deepseek-v4.1-flash-maas, zai-org/glm-5.2-maas and openai/gpt-oss-120b-maas do. magpie asks it on Google's OpenAI-compatible chat completions in your project, with the same credentials and nothing to set. Type in another one (in preview, or listed later) under its full id:

Terminal
magpie provider models google-vertex gemini-3.8-flash deepseek-ai/deepseek-v4.1-flash-maas google/gemma-4-26b-a4b-it-maas
magpie provider models google-vertex all     # back to the location's list
magpie provider test google-vertex zai-org/glm-5.2-maas

Turn each partner model on for the project in Model Garden first: until then Google refuses it. magpie provider test google-vertex tests Gemini; test a partner model on its own, by right-clicking it in the app or by naming it after the command.

Claude on Vertex AI

A model whose id starts with claude- is asked on Anthropic's Messages API in your project (streamRawPredict), as Claude Code asks it with CLAUDE_CODE_USE_VERTEX, with nothing more to set. Every agent can use it, whatever API it speaks, Codex and OpenCode included.

Priority PayGo and Flex PayGo

Google's Priority PayGo and Flex PayGo are asked for with request headers. The editor's Headers offers both, X-Vertex-AI-LLM-Request-Type and X-Vertex-AI-LLM-Shared-Request-Type; their values are the ones Google's pages give. From the CLI:

Terminal
magpie provider set google-vertex header.=

Common errors

FAQ

Does Vertex AI need an API key in magpie?

No. magpie signs each request with gcloud's Application Default Credentials, a service account's key file or an impersonated service account. A key is refused.

Can Claude Code use Claude on Vertex AI through magpie?

Yes. claude- models are asked on Anthropic's Messages API, as with CLAUDE_CODE_USE_VERTEX, and Codex, OpenCode and other agents can use them too. Turn the model on in Model Garden first.

Why did the models change when I moved location?

Each location serves models of its own: global has the most, us and eu the newer Flash models, and a region the 2.5 models. Type others in with magpie provider models google-vertex.

What does a 403 PERMISSION_DENIED mean?

The account that signs needs Agent Platform User (roles/aiplatform.user) on the project; when it impersonates a service account, it also needs Service Account Token Creator on that account.

Related: Gemini in Claude Code, Codex, Gemini CLI and OpenCode, DeepSeek in Claude Code, Codex, Gemini CLI and OpenCode. If something fails, see Fixing common errors: 401, 429, 502, 504 and more or ask on Discord.