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): name the absent keyed lanes in health now that a keyless rung is always configured, and pin the suites to the new ladder
nirholas0a30807a248e
diff --git a/api/_lib/ai-image-lanes.js b/api/_lib/ai-image-lanes.jsindex a348430b7..e248fb2f6 100644--- a/api/_lib/ai-image-lanes.js+++ b/api/_lib/ai-image-lanes.js@@ -51,11 +51,16 @@ export function imageLaneConfig() {const nim = Boolean(readEnv('NVIDIA_API_KEY'));const vertex = Boolean(readEnv('GOOGLE_CLOUD_PROJECT')) && vertexImagenEnabled();const replicate = Boolean(readEnv('REPLICATE_API_TOKEN'));+ const hf = Boolean(readEnv('HF_TOKEN'));+ // Pollinations needs no key, so an image lane is always configured.+ const pollinations = true;return {nim,vertex,replicate,- anyConfigured: nim || vertex || replicate,+ hf,+ pollinations,+ anyConfigured: true,};}@@ -246,6 +251,13 @@ export async function imageLaneHealth() {configured: anyConfigured,healthy: anyReachable,lanes,- missing_env: anyConfigured ? [] : missingLaneEnv(),+ // The keyless rung means `configured` is always true, so this names the+ // KEYED lanes an operator has not brought up, not "nothing at all".+ missing_env: [+ ...(nim.configured ? [] : IMAGE_LANE_ENV.nim),+ ...(vertex.configured ? [] : IMAGE_LANE_ENV.vertex.slice(0, 2)),+ ...(hf.configured ? [] : ['HF_TOKEN']),+ ...(replicate.configured ? [] : IMAGE_LANE_ENV.replicate),+ ],};}diff --git a/tests/api/llm.test.js b/tests/api/llm.test.jsindex b01f8e501..e4a02a2f8 100644--- a/tests/api/llm.test.js+++ b/tests/api/llm.test.js@@ -135,7 +135,7 @@ describe('llmComplete — free platform providers', () => {const out = await llm.llmComplete({ system: 's', user: 'u', preferNvidia: true });expect(out.provider).toBe('nvidia');expect(out.text).toBe('from nemotron');- expect(out.model).toBe('nvidia/nvidia-nemotron-nano-9b-v2');+ expect(out.model).toBe('nvidia/nemotron-3-nano-30b-a3b');// NVIDIA was hit first; Groq never needed.expect(calls[0].url).toContain(NVIDIA_HOST);expect(calls.some((c) => c.url.includes(GROQ_HOST))).toBe(false);diff --git a/tests/api/text-to-image.test.js b/tests/api/text-to-image.test.jsindex 08e3bf048..aa76ce068 100644--- a/tests/api/text-to-image.test.js+++ b/tests/api/text-to-image.test.js@@ -148,7 +148,7 @@ describe('textToImage: Vertex quality lane leads by default', () => {const textToImage = await freshTextToImage();const result = await textToImage('a red teapot');- expect(result.model).toBe('black-forest-labs/flux.1-schnell');+ expect(result.model).toBe('black-forest-labs/flux.1-dev');expect(vertexState.generate).toHaveBeenCalledOnce();expect(calls).toHaveLength(1);});@@ -164,7 +164,7 @@ describe('textToImage: Vertex quality lane leads by default', () => {const textToImage = await freshTextToImage();const result = await textToImage('a red teapot');- expect(result.model).toBe('black-forest-labs/flux.1-schnell');+ expect(result.model).toBe('black-forest-labs/flux.1-dev');expect(vertexState.generate).not.toHaveBeenCalled();expect(calls).toHaveLength(1);});@@ -188,7 +188,7 @@ describe('textToImage: NIM FLUX free lane (legacy NIM-first order)', () => {const textToImage = await freshTextToImage();const result = await textToImage('a red teapot');- expect(result.model).toBe('black-forest-labs/flux.1-schnell');+ expect(result.model).toBe('black-forest-labs/flux.1-dev');// NIM output is JPEG, persisted bytes, key extension, and Content-Type// must all say jpeg, not png (regression cover for the probe finding).expect(result.imageUrl).toMatch(/^https:\/\/cdn\.example\/forge\/refs\/.+\.jpg$/);@@ -199,9 +199,9 @@ describe('textToImage: NIM FLUX free lane (legacy NIM-first order)', () => {expect(Buffer.compare(r2State.puts[0].body, NIM_JPEG_BYTES)).toBe(0);expect(vertexState.generate).not.toHaveBeenCalled();expect(calls).toHaveLength(1);- expect(calls[0].url).toContain('flux.1-schnell');+ expect(calls[0].url).toContain('flux.1-dev');expect(calls[0].body.prompt).toMatch(/^a red teapot/);- expect(calls[0].body).toMatchObject({ steps: 4 });+ expect(calls[0].body).toMatchObject({ steps: 20, cfg_scale: 3.5 });// schnell is guidance-distilled: the endpoint 422s on cfg_scale > 0// (verified live), so the request must not send it at all.expect(calls[0].body).not.toHaveProperty('cfg_scale');@@ -284,7 +284,7 @@ describe('textToImage: NIM FLUX free lane (legacy NIM-first order)', () => {const p = textToImage('a red teapot');await vi.advanceTimersByTimeAsync(2_000); // let the retry backoff elapseconst result = await p;- expect(result.model).toBe('black-forest-labs/flux.1-schnell');+ expect(result.model).toBe('black-forest-labs/flux.1-dev');expect(calls.filter((c) => c.url.includes('ai.api.nvidia.com'))).toHaveLength(2);} finally {vi.useRealTimers();@@ -316,12 +316,20 @@ describe('textToImage: NIM FLUX free lane (legacy NIM-first order)', () => {expect(calls.filter((c) => c.url.includes('ai.api.nvidia.com'))).toHaveLength(1);});- it('surfaces the NIM error when it is the only configured lane', async () => {+ // There is no "only configured lane" any more: keyless Pollinations always+ // sits behind the keyed rungs. NIM's failure is logged and the ladder walks+ // on; the terminal error is the LAST rung's, so a diagnosis reads the warns.+ it('walks past a NIM failure to the keyless rung, and the terminal error is the last rung\'s', async () => {process.env.NVIDIA_API_KEY = 'nvapi-test';- stubFetch([['ai.api.nvidia.com', () => new Response('nope', { status: 401 })]]);+ const calls = stubFetch([+ ['ai.api.nvidia.com', () => new Response('nope', { status: 401 })],+ ['image.pollinations.ai', () => new Response('down', { status: 503 })],+ ]);+ vi.spyOn(console, 'warn').mockImplementation(() => {});const textToImage = await freshTextToImage();- await expect(textToImage('a red teapot')).rejects.toThrow(/nim flux returned 401/);+ await expect(textToImage('a red teapot')).rejects.toThrow(/pollinations returned 503/);+ expect(calls.some((c) => c.url.includes('ai.api.nvidia.com'))).toBe(true);});it('skipNim bypasses the NIM lane entirely when a fallback exists', async () => {@@ -338,15 +346,18 @@ describe('textToImage: NIM FLUX free lane (legacy NIM-first order)', () => {expect(calls.some((c) => c.url.includes('ai.api.nvidia.com'))).toBe(false);});- it('skipNim still uses NIM when it is the only lane (never skip into a dead end)', async () => {+ it('skipNim with no keyed fallback still lands on the keyless rung, never a dead end', async () => {process.env.NVIDIA_API_KEY = 'nvapi-test';- const calls = stubFetch([['ai.api.nvidia.com', () => nimSuccessResponse()]]);+ const calls = stubFetch([+ ['ai.api.nvidia.com', () => nimSuccessResponse()],+ ['image.pollinations.ai', () => new Response(new Uint8Array([0xff, 0xd8, 0xff, 0xe0, 0, 0, 0, 0]), { status: 200, headers: { 'content-type': 'image/jpeg' } })],+ ]);const textToImage = await freshTextToImage();const result = await textToImage('a red teapot', { skipNim: true });- expect(result.model).toBe('black-forest-labs/flux.1-schnell');- expect(calls.filter((c) => c.url.includes('ai.api.nvidia.com'))).toHaveLength(1);+ expect(result.model).toBe('pollinations/flux');+ expect(calls.some((c) => c.url.includes('ai.api.nvidia.com'))).toBe(false);});it('a degraded NIM failure cools the lane so the next call skips it', async () => {@@ -450,13 +461,18 @@ describe('textToImage: Livepeer federation lane counts as a real fallback', () =expect(calls.some((c) => c.url.includes('gateway.test/images/'))).toBe(true);});- it('still surfaces the upstream error when Livepeer federation is off', async () => {+ it('with Livepeer off, the keyless rung is what stands between NIM and a dead end', async () => {delete process.env.LIVEPEER_FEDERATION_ENABLED;process.env.NVIDIA_API_KEY = 'nvapi-test';- stubFetch([['ai.api.nvidia.com', () => new Response('nope', { status: 401 })]]);+ const calls = stubFetch([+ ['ai.api.nvidia.com', () => new Response('nope', { status: 401 })],+ ['image.pollinations.ai', () => new Response('down', { status: 503 })],+ ]);+ vi.spyOn(console, 'warn').mockImplementation(() => {});const textToImage = await freshTextToImage();- await expect(textToImage('a red teapot')).rejects.toThrow(/nim flux returned 401/);+ await expect(textToImage('a red teapot')).rejects.toThrow(/pollinations returned 503/);+ expect(calls.some((c) => c.url.includes('gateway.test'))).toBe(false);});});diff --git a/tests/api/v1-ai-image.test.js b/tests/api/v1-ai-image.test.jsindex 8432cc8e3..4e4cd1c8a 100644--- a/tests/api/v1-ai-image.test.js+++ b/tests/api/v1-ai-image.test.js@@ -198,15 +198,14 @@ describe('quota fall-through to x402', () => {});describe('no-lane honesty', () => {- it('returns 503 not_configured naming the env vars when no lane is set', async () => {- delete process.env.NVIDIA_API_KEY; // no lane configured at all+ // Keyless Pollinations is always behind the keyed rungs, so "no key at all"+ // is no longer "no lane": the request still runs, and the health surface is+ // where the absent keyed lanes are named (see the GET ?health=1 case).+ it('still serves with no keyed lane set, through the keyless rung', async () => {+ delete process.env.NVIDIA_API_KEY;const res = makeRes();await handler(makeReq({ body: { prompt: 'a brass owl figurine' } }), res);- expect(res.statusCode).toBe(503);- const body = JSON.parse(res.body);- expect(body.error).toBe('not_configured');- expect(body.error_description).toContain('NVIDIA_API_KEY');- expect(body.error_description).toContain('GOOGLE_CLOUD_PROJECT');+ expect(res.statusCode).toBe(200);});});@@ -235,13 +234,16 @@ describe('GET surfaces', () => {expect(body.price_usdc).toBe('0.020000');});- it('reports per-lane health on GET ?health=1 without a lane configured → 503', async () => {+ // Keyless Pollinations means the image surface is never "unconfigured":+ // with no key at all it still answers 200 and names the keyed lanes missing.+ it('reports per-lane health on GET ?health=1 with no keyed lane: still configured via the keyless rung', async () => {delete process.env.NVIDIA_API_KEY;const res = makeRes();await handler(makeReq({ method: 'GET', url: '/api/v1/ai/image?health=1' }), res);- expect(res.statusCode).toBe(503);+ expect(res.statusCode).toBe(200);const body = JSON.parse(res.body);- expect(body.configured).toBe(false);+ expect(body.configured).toBe(true);+ expect(body.lanes.pollinations.configured).toBe(true);expect(body.lanes.nim.status).toBe('unconfigured');expect(body.missing_env).toContain('NVIDIA_API_KEY');});