惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
GbyAI
GbyAI
M
MIT News - Artificial intelligence
美团技术团队
罗磊的独立博客
雷峰网
雷峰网
量子位
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
D
Docker
小众软件
小众软件
S
SegmentFault 最新的问题
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
WordPress大学
WordPress大学
V
V2EX
博客园_首页
腾讯CDC
The Cloudflare Blog
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
"My Team Had GCP Credits. Claude Code Wanted an Anthropic...
CodeKing · 2026-05-09 · via DEV Community

I already had Google Cloud billing.

I did not want another API key, another quota surface, and another place to explain to my team why the coding tool bill was showing up somewhere else.

The annoying part was that Claude Code speaks Anthropic's Messages API, while the budget I wanted to use was sitting in Vertex AI.

So I wired the two together through a local gateway.

The mismatch

If you try to connect Claude Code to Vertex AI directly, the shapes do not line up cleanly.

Claude Code expects this kind of world:

  • POST /v1/messages
  • Anthropic headers
  • Anthropic content blocks
  • Anthropic streaming semantics

Vertex AI is a different world.

For Claude models on Vertex, the request goes to a publisher endpoint like:

.../publishers/anthropic/models/claude-sonnet-4-6:rawPredict

Enter fullscreen mode Exit fullscreen mode

For Gemini models on Vertex, it goes to:

.../publishers/google/models/gemini-2.5-pro:generateContent

Enter fullscreen mode Exit fullscreen mode

That meant I needed something in the middle that could accept Claude Code exactly as-is, then decide how to talk to Vertex on the other side.

What I used

I used CliGate, a local gateway that already sits between Claude Code, Codex CLI, Gemini CLI, and multiple upstream providers.

The useful part for this setup is that Vertex AI is just another API-key-backed upstream inside the same routing layer.

In this project, a Vertex key stores three things that matter:

  • type: vertex-ai
  • projectId
  • location

And the apiKey field can hold the full Google service account JSON.

The 5-minute setup

1. Start the gateway

npx cligate@latest start

Enter fullscreen mode Exit fullscreen mode

Default dashboard:

http://localhost:8081

Enter fullscreen mode Exit fullscreen mode

2. Add Vertex AI as an API key provider

You can do it in the dashboard, or post it directly:

curl -X POST http://localhost:8081/api/keys \
  -H "Content-Type: application/json" \
  -d '{
    "type": "vertex-ai",
    "name": "vertex-work",
    "apiKey": "{\"type\":\"service_account\",\"project_id\":\"my-project\", ... }",
    "projectId": "my-project",
    "location": "us-central1"
  }'

Enter fullscreen mode Exit fullscreen mode

That apiKey value looks strange because it is not a normal API key string. For Vertex AI in CliGate, it can be the full service account JSON blob.

3. Point Claude Code at localhost

export ANTHROPIC_BASE_URL=http://localhost:8081
export ANTHROPIC_API_KEY=any-key
claude

Enter fullscreen mode Exit fullscreen mode

Now Claude Code still thinks it is talking to an Anthropic-compatible server.

It is.

That server just happens to decide that the real upstream should be Vertex AI.

The part that made this worth doing

The nice thing about this setup is that I did not need to patch Claude Code itself.

Claude Code keeps sending Anthropic-style requests to:

POST /v1/messages

Enter fullscreen mode Exit fullscreen mode

CliGate inspects the model and the selected provider, then takes one of two paths:

Claude Code
  -> /v1/messages
  -> CliGate
  -> Vertex Claude rawPredict

Enter fullscreen mode Exit fullscreen mode

or:

Claude Code
  -> /v1/messages
  -> CliGate
  -> Anthropic-to-Gemini bridge on Vertex

Enter fullscreen mode Exit fullscreen mode

That second path is the interesting one. The provider code treats Vertex differently depending on the model family:

  • claude-* models keep the Anthropic-style path on Vertex
  • gemini-* models are translated into Gemini generateContent

So one local entry point can still switch between Claude-on-Vertex and Gemini-on-Vertex without Claude Code learning a new protocol.

The subtle detail I was glad the project handled

There is one implementation detail here that usually gets hand-waved away in blog posts: location.

Vertex AI does not treat every model family the same way.

In CliGate's provider implementation, Gemini can use the Google publisher endpoints, while Claude models on Vertex still need the Anthropic publisher path, and regional handling matters. That is why the stored config keeps both:

  • projectId
  • location

For me, this was the difference between "works in a diagram" and "works at 11 PM when I just want the CLI to answer."

Why I preferred this over another direct integration

I could have built a one-off wrapper just for Claude Code + Vertex AI.

That would have solved today's problem and created tomorrow's mess.

The local gateway approach was better because the same control plane already handles:

  • Claude Code
  • Codex CLI
  • Gemini CLI
  • API key routing
  • account pools
  • usage and pricing views

So moving Claude Code onto GCP credits did not create another isolated config path. It became one routing rule inside the system I was already using.

What this setup buys me in practice

After the proxy is in place, the workflow gets boring in the best way:

  1. Claude Code still points to http://localhost:8081
  2. Vertex AI holds the real billing surface
  3. the dashboard keeps request logs, usage, and provider visibility
  4. I can swap models or providers later without rewiring the CLI again

That last part matters more than it sounds. I do not want my tools to know where the money comes from. I want them to know where the gateway is.

If you already have GCP credits, this is the easiest way I found

If your team already runs on Google Cloud, making Claude Code consume Vertex AI instead of another standalone Anthropic key is mostly a protocol-translation problem.

Once that translation sits on localhost, the rest of the setup becomes very small.

Repo:

CliGate on GitHub

I'm curious how other people are handling this split right now: are you connecting Claude Code straight to Vertex, or hiding the provider switch behind one local gateway too?