Google Vertex

The @typochat-sdk/google-vertex package is a drop-in replacement for @ai-sdk/google-vertex. It routes Gemini requests through the TypoMonster proxy using Vertex AI Express Mode, so your app uses a TypoMonster API key instead of Google Cloud credentials.

Use @typochat-sdk/google for Google AI Studio. Use @typochat-sdk/google-vertex when you want the Vertex provider path.

Installation

bash
npm install @typochat-sdk/google-vertex ai

Setup

typescript
import { createProxyVertex } from "@typochat-sdk/google-vertex";
 
const vertex = createProxyVertex({
  apiKey: "tmk_your_api_key_here", // express mode
});

You can also configure via environment variables instead of passing them directly:

VariableDescription
NEXT_PUBLIC_AI_PROXY_KEYYour TypoMonster API key (tmk_...)
NEXT_PUBLIC_AI_PROXY_URLProxy URL (defaults to https://chat-api.typo.monster)
typescript
// When env vars are set, no config needed
const vertex = createProxyVertex();

Context Keys

Pass a contextKey to group related requests and improve cache hit rates:

typescript
const vertex = createProxyVertex({
  apiKey: "tmk_your_api_key_here", // express mode
  contextKey: "chat-session-abc123",
});

Available Models

Google Vertex uses the same Gemini model list as the Google provider:

ModelDescription
gemini-3.1-pro-previewMost capable preview model
gemini-3.1-flash-lite-previewLightweight Gemini 3.1 preview model
gemini-3-flash-previewGemini 3 flash preview model
gemini-2.5-proCapable model for complex tasks
gemini-2.5-flashFast and efficient, great balance of speed and quality
gemini-2.5-flash-liteLightweight model for simple tasks

Text Generation

typescript
import { createProxyVertex } from "@typochat-sdk/google-vertex";
import { generateText } from "ai";
 
const vertex = createProxyVertex({
  apiKey: "tmk_your_api_key_here", // express mode
});
 
const { text } = await generateText({
  model: vertex("gemini-3.1-flash-lite-preview"),
  prompt: "What is the capital of France?",
});
 
console.log(text);

Streaming

typescript
import { createProxyVertex } from "@typochat-sdk/google-vertex";
import { streamText } from "ai";
 
const vertex = createProxyVertex({
  apiKey: "tmk_your_api_key_here", // express mode
});
 
const result = streamText({
  model: vertex("gemini-3.1-flash-lite-preview"),
  prompt: "Write a short story about a robot.",
});
 
for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

Reasoning (Thinking)

Vertex uses vertex provider options:

typescript
import { createProxyVertex } from "@typochat-sdk/google-vertex";
import { generateText } from "ai";
 
const vertex = createProxyVertex({
  apiKey: "tmk_your_api_key_here", // express mode
});
 
const { text, reasoning } = await generateText({
  model: vertex("gemini-2.5-flash"),
  prompt: "How many r's are in the word strawberry?",
  providerOptions: {
    vertex: {
      thinkingConfig: { includeThoughts: true },
    },
  },
});
 
console.log("Answer:", text);
console.log("Reasoning:", reasoning);

To disable thinking for supported models:

typescript
providerOptions: {
  vertex: {
    thinkingConfig: { thinkingBudget: 0 },
  },
}

Migrating from @ai-sdk/google-vertex

The migration is a small provider setup change:

diff
- import { createVertex } from "@ai-sdk/google-vertex/edge";
+ import { createProxyVertex } from "@typochat-sdk/google-vertex";
 
- const vertex = createVertex({
-   project: "YOUR_GOOGLE_CLOUD_PROJECT",
-   location: "global",
- });
+ const vertex = createProxyVertex({
+   apiKey: "tmk_your_api_key_here", // express mode
+ });
 
// Everything below stays exactly the same
const { text } = await generateText({
  model: vertex("gemini-3.1-flash-lite-preview"),
  prompt: "Hello!",
});

Direct HTTP

You can call Vertex through the proxy without an SDK:

bash
curl -X POST \
  'https://chat-api.typo.monster/proxy?url=https://aiplatform.googleapis.com/v1/publishers/google/models/gemini-3.1-flash-lite-preview:generateContent' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer tmk_your_api_key_here' \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "Hello!"}]}]
  }'

The proxy rewrites the Express Mode URL to the configured Vertex project and location before forwarding upstream.

Next Steps