Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat(ai-gateway): promote gemini-3.5-flash to top of auto waterfall

Louis Beaumontf8345627d587
diff --git a/packages/ai-gateway/src/handlers/chat.ts b/packages/ai-gateway/src/handlers/chat.ts
index 59bca6bbe..c6e179fe6 100644
--- a/packages/ai-gateway/src/handlers/chat.ts
+++ b/packages/ai-gateway/src/handlers/chat.ts
@@ -7,8 +7,11 @@ import { addCorsHeaders } from '../utils/cors';
import { logModelOutcome } from '../services/model-health';
import { captureException } from '@sentry/cloudflare';
-// Auto model waterfall — ordered by quality/cost ratio (all free or near-free).
+// Auto model waterfall — quality first, then fall back to open-weight Vertex
+// MaaS picks (free for users, near-zero GCP burn) and a cheap Gemini safety
+// net at the tail.
const AUTO_WATERFALL = [
+ 'gemini-3.5-flash', // new flagship flash — beats pro tier on agent benchmarks
'kimi-k2.5',
'deepseek-v3.2',
'glm-4.7',
@@ -17,6 +20,7 @@ const AUTO_WATERFALL = [
// Vision-capable models for requests containing images
const AUTO_WATERFALL_VISION = [
+ 'gemini-3.5-flash', // multimodal, leads on agent/vision benchmarks
'llama-4-maverick', // free (Vertex MaaS), 400B MoE, strong vision + reasoning
'gemini-3-flash', // near-free, good vision
'llama-4-scout', // free (Vertex MaaS), 109B MoE, decent vision fallback
diff --git a/packages/ai-gateway/src/services/cost-tracker.ts b/packages/ai-gateway/src/services/cost-tracker.ts
index b0c77f116..d8724a982 100644
--- a/packages/ai-gateway/src/services/cost-tracker.ts
+++ b/packages/ai-gateway/src/services/cost-tracker.ts
@@ -54,6 +54,10 @@ const MODEL_PRICING: Record<string, ModelPricing> = {
'gemini-2.5-pro': { input: 1.25, output: 10.00 },
'gemini-3-flash': { input: 0.10, output: 0.40 },
'gemini-3-pro': { input: 1.25, output: 10.00 },
+ // 3.5-flash routes through Vertex global endpoint (see gemini.ts
+ // requiresGlobalEndpoint), so we pay the cheaper global tier — $1.50/$9
+ // vs $1.65/$9.90 for regional.
+ 'gemini-3.5-flash': { input: 1.50, output: 9.00 },
'gemini-3.1-flash-lite': { input: 0.25, output: 1.50 },
'gemini-1.5-flash': { input: 0.075, output: 0.30 },
'gemini-1.5-pro': { input: 1.25, output: 5.00 },