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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(image-lanes): probe Vertex with countTokens, not a model-list read that 404s either way
nirholas3e7d552178f2
diff --git a/api/_lib/ai-image-lanes.js b/api/_lib/ai-image-lanes.jsindex 3156fda4d..96e012fac 100644--- a/api/_lib/ai-image-lanes.js+++ b/api/_lib/ai-image-lanes.js@@ -182,26 +182,41 @@ async function probeVertex() {// 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.+ // image (observed 2026-08-27). Ask the API itself.+ //+ // countTokens, specifically: it is free, consumes no image quota, and+ // runs the same project + publisher-model path a real generate does, so+ // it fails with the identical project-level denial. The read-only+ // endpoints (publishers/models) were tried first and are wrong for this:+ // they 404 with an HTML body on the regional host whether or not the+ // project is healthy, which would report a working lane as down.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),- });+ const res = await fetch(+ `${host}/v1/projects/${project}/locations/${location}/publishers/google/models/${model}:countTokens`,+ {+ method: 'POST',+ headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },+ body: JSON.stringify({ contents: [{ role: 'user', parts: [{ text: 'x' }] }] }),+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),+ },+ );if (res.ok) return { configured: true, status: 'ok', model, location };const body = await res.text().catch(() => '');+ let message = body.slice(0, 120);+ try {+ message = JSON.parse(body)?.error?.message || message;+ } catch {+ /* a non-JSON body (an HTML gateway error) keeps the raw prefix */+ }// 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: 'down',httpStatus: res.status,- detail: dunning+ detail: /dunning/i.test(message)? 'project billing is in dunning: generative APIs denied until the billing account is settled'- : body.slice(0, 120) || `HTTP ${res.status}`,+ : message.slice(0, 120) || `HTTP ${res.status}`,model,location,};diff --git a/tests/image-lane-health.test.js b/tests/image-lane-health.test.jsindex 2d91a3416..871232ac4 100644--- a/tests/image-lane-health.test.js+++ b/tests/image-lane-health.test.js@@ -41,7 +41,25 @@ 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();+ // countTokens specifically: free, no image quota, and the same project ++ // publisher-model path a real generate takes. The read-only model-list+ // endpoints 404 with HTML on the regional host even when the lane works.+ const call = globalThis.fetch.mock.calls.find(([u]) => String(u).includes('aiplatform'));+ expect(String(call[0])).toContain(':countTokens');+ expect(call[1].method).toBe('POST');+ });++ it('reads the message out of a JSON error body rather than dumping the raw payload', async () => {+ vertex.respond = () => new Response(JSON.stringify({ error: { message: 'Permission denied on resource project.' } }), { status: 403 });+ const h = await imageLaneHealth();+ expect(h.lanes.vertex.detail).toBe('Permission denied on resource project.');+ });++ it('survives a non-JSON gateway body without leaking a page of HTML into health', async () => {+ vertex.respond = () => new Response('<!DOCTYPE html><html lang=en><title>Error 404</title>', { status: 404 });+ const h = await imageLaneHealth();+ expect(h.lanes.vertex.status).toBe('down');+ expect(h.lanes.vertex.detail.length).toBeLessThanOrEqual(120);});it('is down, and names the billing hold, when the project is in dunning', async () => {