Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(image-lanes): make the Vertex probe call the API instead of only minting a token

nirholasb71b8135f439
diff --git a/api/_lib/ai-image-lanes.js b/api/_lib/ai-image-lanes.js
index e248fb2f6..3156fda4d 100644
--- a/api/_lib/ai-image-lanes.js
+++ b/api/_lib/ai-image-lanes.js
@@ -174,16 +174,39 @@ async function probeVertex() {
model: readEnv('VERTEX_IMAGEN_MODEL') || 'gemini-2.5-flash-image',
};
}
+ const model = readEnv('VERTEX_IMAGEN_MODEL') || 'gemini-2.5-flash-image';
+ const location = readEnv('GOOGLE_CLOUD_LOCATION') || 'us-central1';
try {
- await getGcpAccessToken();
+ const token = await getGcpAccessToken();
+ // Minting a token proves the service account, NOT that Vertex will serve.
+ // A project in billing dunning hands out tokens happily and then 403s
+ // every generative call ("Lightning dunning decision is deny"), which
+ // this probe reported as `ok` for a lane that could not paint a single
+ // image (observed 2026-08-27). Ask the API itself: listing publisher
+ // models is free, needs no quota, and fails with the same project-level
+ // denial a real generate would.
+ const host = location === 'global' ? 'https://aiplatform.googleapis.com' : `https://${location}-aiplatform.googleapis.com`;
+ const res = await fetch(`${host}/v1/publishers/google/models?pageSize=1`, {
+ headers: { authorization: `Bearer ${token}` },
+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
+ });
+ if (res.ok) return { configured: true, status: 'ok', model, location };
+ const body = await res.text().catch(() => '');
+ // Name the billing hold explicitly: it reads like an IAM problem and
+ // sends operators chasing service-account roles instead of the console.
+ const dunning = /dunning/i.test(body);
return {
configured: true,
- status: 'ok',
- model: readEnv('VERTEX_IMAGEN_MODEL') || 'gemini-2.5-flash-image',
- location: readEnv('GOOGLE_CLOUD_LOCATION') || 'us-central1',
+ status: 'down',
+ httpStatus: res.status,
+ detail: dunning
+ ? 'project billing is in dunning: generative APIs denied until the billing account is settled'
+ : body.slice(0, 120) || `HTTP ${res.status}`,
+ model,
+ location,
};
} catch (err) {
- return { configured: true, status: 'down', detail: err?.message?.slice(0, 120) };
+ return { configured: true, status: 'down', detail: err?.message?.slice(0, 120), model, location };
}
}
diff --git a/tests/image-lane-health.test.js b/tests/image-lane-health.test.js
new file mode 100644
index 000000000..2d91a3416
--- /dev/null
+++ b/tests/image-lane-health.test.js
@@ -0,0 +1,72 @@
+/**
+ * imageLaneHealth (api/_lib/ai-image-lanes.js) must report what a lane will
+ * actually DO, not what it is configured to do.
+ *
+ * On 2026-08-27 the Vertex probe reported `ok` while every real Vertex call
+ * 403'd: the project was in billing dunning, which still hands out access
+ * tokens, and the probe only minted one. Text-to-3D had no working image lane
+ * for hours while health read green.
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
+delete process.env.NVIDIA_API_KEY;
+delete process.env.REPLICATE_API_TOKEN;
+delete process.env.HF_TOKEN;
+
+vi.mock('../api/_lib/gcp-auth.js', () => ({
+ getGcpAccessToken: async () => 'token',
+ gcpAuthConfigured: () => true,
+}));
+vi.mock('../api/_lib/provider-health.js', () => ({
+ providersInCooldown: async () => new Set(),
+ markProviderCooldown: async () => {},
+}));
+
+const vertex = { respond: null };
+globalThis.fetch = vi.fn(async (url) => {
+ const u = String(url);
+ if (u.includes('aiplatform.googleapis.com')) return vertex.respond();
+ if (u.includes('pollinations')) return new Response(null, { status: 200 });
+ throw new Error(`unexpected fetch ${u}`);
+});
+
+const { imageLaneHealth } = await import('../api/_lib/ai-image-lanes.js');
+
+beforeEach(() => {
+ vertex.respond = () => new Response('{}', { status: 200 });
+});
+
+describe('vertex probe reports real serving ability', () => {
+ it('is ok when the API answers, not merely when a token mints', async () => {
+ const h = await imageLaneHealth();
+ expect(h.lanes.vertex.status).toBe('ok');
+ expect(globalThis.fetch).toHaveBeenCalled();
+ });
+
+ it('is down, and names the billing hold, when the project is in dunning', async () => {
+ vertex.respond = () =>
+ new Response(JSON.stringify({ error: { message: 'Lightning dunning decision is deny for project: projects/93741856042' } }), { status: 403 });
+ const h = await imageLaneHealth();
+ expect(h.lanes.vertex.status).toBe('down');
+ expect(h.lanes.vertex.httpStatus).toBe(403);
+ // The message reads like an IAM problem; say what it actually is.
+ expect(h.lanes.vertex.detail).toMatch(/billing/i);
+ });
+
+ it('is down on any other API refusal, carrying the status', async () => {
+ vertex.respond = () => new Response('quota exhausted', { status: 429 });
+ const h = await imageLaneHealth();
+ expect(h.lanes.vertex.status).toBe('down');
+ expect(h.lanes.vertex.httpStatus).toBe(429);
+ });
+
+ it('still reports the surface configured through the keyless rung, and names the absent keyed lanes', async () => {
+ vertex.respond = () => new Response('denied', { status: 403 });
+ const h = await imageLaneHealth();
+ expect(h.configured).toBe(true);
+ expect(h.lanes.pollinations.status).toBe('ok');
+ expect(h.missing_env).toContain('NVIDIA_API_KEY');
+ expect(h.missing_env).toContain('HF_TOKEN');
+ });
+});