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.

feat(forge): register free NVIDIA NIM TRELLIS backend as the draft-tier default

nirholasc5fb3f3d57ff
diff --git a/api/_lib/forge-tiers.js b/api/_lib/forge-tiers.js
index 4e0931534..713d49c1b 100644
--- a/api/_lib/forge-tiers.js
+++ b/api/_lib/forge-tiers.js
@@ -92,6 +92,25 @@ export function priceUsdcForTier(tier) {
// vendor credit spend per (path → tier) — null when the backend bills by GPU
// time rather than credits (TRELLIS/Hunyuan via our own infra).
export const BACKENDS = Object.freeze({
+ nvidia: Object.freeze({
+ id: 'nvidia',
+ label: 'TRELLIS (free)',
+ vendor: 'Microsoft TRELLIS · NVIDIA NIM',
+ paths: Object.freeze(['image']),
+ byok: false,
+ provider: 'nvidia',
+ requiresEnv: Object.freeze(['NVIDIA_API_KEY']),
+ polyControl: false,
+ // Provisional estimate pending the live T0.2 TRELLIS probe — NVCF keeps the
+ // GPU warm so wall-clock runs well under Replicate's cold-start ~60s; revise
+ // from probes/trellis.md latencies once recorded (T0.2/T1.5).
+ baseEta: 25,
+ credits: null,
+ // Free NVIDIA NIM lane — no vendor credit cost. This is what makes it the
+ // free-first draft default per platform policy.
+ free: true,
+ blurb: 'Free TRELLIS reconstruction on NVIDIA NIM. The default draft lane; no vendor cost.',
+ }),
trellis: Object.freeze({
id: 'trellis',
label: 'TRELLIS',
@@ -162,12 +181,34 @@ export const DEFAULT_BACKEND_FOR_PATH = Object.freeze({
geometry: 'meshy',
});
-export function resolveBackendId({ path, backend }) {
+// Free-first override: when the caller asks for the draft tier without naming a
+// backend, prefer the free NVIDIA NIM lane (platform LLM/free-first policy) on
+// the paths it serves — but only when it's actually configured, so a deployment
+// without NVIDIA_API_KEY transparently keeps the standing per-path default. Paid
+// backends (Replicate/Meshy/Tripo) stay fully selectable at every tier.
+export const FREE_DEFAULT_FOR_DRAFT = Object.freeze({
+ image: 'nvidia',
+});
+
+// Resolve the default backend for a (path, tier) when the caller didn't name
+// one. Tier matters because the draft tier routes to the free lane first.
+function defaultBackendFor(p, tierId) {
+ if (tierId === 'draft') {
+ const free = FREE_DEFAULT_FOR_DRAFT[p];
+ if (free && BACKENDS[free] && BACKENDS[free].paths.includes(p) && backendIsConfigured(free)) {
+ return free;
+ }
+ }
+ return DEFAULT_BACKEND_FOR_PATH[p];
+}
+
+export function resolveBackendId({ path, tier, backend }) {
const p = PATHS.includes(path) ? path : DEFAULT_PATH;
if (backend && BACKENDS[backend] && BACKENDS[backend].paths.includes(p)) {
return backend;
}
- return DEFAULT_BACKEND_FOR_PATH[p];
+ const tierId = tier?.id || tier || DEFAULT_TIER;
+ return defaultBackendFor(p, tierId);
}
function readEnv(name) {
@@ -215,6 +256,15 @@ export function buildCatalog() {
default_path: DEFAULT_PATH,
default_tier: DEFAULT_TIER,
default_backend: DEFAULT_BACKEND_FOR_PATH,
+ // Tier-aware defaults so the UI can show which engine a tier picks when the
+ // user doesn't override it. Draft prefers the free lane where it's live.
+ default_backend_for_tier: TIER_IDS.reduce((acc, tierId) => {
+ acc[tierId] = PATHS.reduce((byPath, p) => {
+ byPath[p] = resolveBackendId({ path: p, tier: tierId });
+ return byPath;
+ }, {});
+ return acc;
+ }, {}),
tiers: TIER_IDS.map((id) => {
const t = TIERS[id];
return {
@@ -235,6 +285,7 @@ export function buildCatalog() {
paths: b.paths,
byok: b.byok || null,
poly_control: b.polyControl,
+ free: Boolean(b.free),
configured: backendIsConfigured(b.id),
blurb: b.blurb,
estimates: b.paths.reduce((acc, p) => {
diff --git a/api/forge.js b/api/forge.js
index f9cbf282e..01ec4f4e3 100644
--- a/api/forge.js
+++ b/api/forge.js
@@ -26,6 +26,7 @@
* model.
*/
+import { randomUUID } from 'node:crypto';
import { cors, json, method, readJson, wrap, rateLimited } from './_lib/http.js';
import { limits, clientIp } from './_lib/rate-limit.js';
import { textToImage } from './_mcp3d/text-to-image.js';
@@ -56,6 +57,16 @@ import {
findByJob,
} from './_lib/forge-store.js';
+// The free NVIDIA NIM (TRELLIS) provider is loaded lazily and dynamically: it
+// ships in T1.1, so importing it statically would couple this whole endpoint to
+// a module that may not exist yet. Dynamic import keeps every other backend
+// working in the meantime; a missing module or absent NVIDIA_API_KEY surfaces as
+// a clean backend_unconfigured 501 at the dispatch sites below.
+async function loadNvidiaProvider() {
+ const mod = await import('./_providers/nvidia.js');
+ return mod.createNvidiaProvider();
+}
+
const VALID_ASPECT = new Set(['1:1', '4:3', '3:4', '16:9', '9:16']);
// Multi-view reconstruction accepts up to four calibrated views of one object
@@ -187,7 +198,9 @@ async function startJob(req, res) {
// intermediate vs geometry-first) and which quality tier (poly budget).
const path = parsePath(body);
const tier = resolveTier(parseTier(body));
- const backendId = resolveBackendId({ path, backend: body?.backend });
+ // Tier matters to backend selection: the draft tier routes to the free NVIDIA
+ // NIM lane first (when configured) per the platform free-first policy.
+ const backendId = resolveBackendId({ path, tier, backend: body?.backend });
try {
// ── Geometry-first path (Meshy / Tripo, BYOK) ───────────────────────────
@@ -262,21 +275,126 @@ async function startJob(req, res) {
});
}
- // ── Image-intermediate path (TRELLIS default, or Hunyuan3D self-host) ────
- let provider;
- try {
- provider = backendId === 'hunyuan3d' ? createGcpProvider() : createRegenProvider();
- } catch {
- // A selected-but-unconfigured self-host backend gets a branchable 501;
- // the default TRELLIS path keeps its existing "not configured" 503.
- if (backendId === 'hunyuan3d') {
- return json(res, 501, {
- error: 'backend_unconfigured',
- backend: 'hunyuan3d',
- message: 'Hunyuan3D self-host is not configured on this deployment.',
+ // ── Free NVIDIA NIM TRELLIS lane (platform-keyed; direct text/image→3D) ──
+ // TRELLIS on NIM emits the mesh natively from a prompt or a single photo
+ // (no FLUX intermediate view), so it exposes meshy-style text/image methods
+ // and a pollable NVCF request id — but it needs no BYOK key. It serves the
+ // image path as the free draft default. NVCF normally returns a poll
+ // handle; on the rare synchronous completion the GLB is already in R2.
+ if (backendId === 'nvidia') {
+ let nv;
+ try {
+ nv = await loadNvidiaProvider();
+ } catch {
+ return json(res, 501, {
+ error: 'backend_unconfigured',
+ backend: 'nvidia',
+ message: 'The free NVIDIA NIM 3D lane is not available on this deployment yet.',
+ });
+ }
+
+ let submitted;
+ let previewImageUrl = null;
+ if (isImageMode) {
+ previewImageUrl = imageUrls[0];
+ submitted = await nv.imageTo3d({ imageUrl: previewImageUrl, tier });
+ } else {
+ submitted = await nv.textTo3d({ prompt, tier });
+ }
+
+ const provenance = {
+ mode: isImageMode ? 'image_to_3d' : 'text_to_3d',
+ path,
+ tier: tier.id,
+ backend: backendId,
+ prompt: prompt || null,
+ preview_image_url: previewImageUrl,
+ reference_image_urls: isImageMode ? [imageUrls[0]] : [],
+ eta_seconds: estimateEtaSeconds({ backendId, tier }),
+ estimated_credits: estimateCredits({ backendId, path, tier }),
+ };
+
+ const clientKey = clientKeyFrom(req);
+ // Synchronous completion: NVCF already persisted the GLB to R2. Record a
+ // finished creation (a synthetic handle lets materialize copy + flip it
+ // to done) and return it so the client skips polling entirely.
+ if (!submitted.taskId && submitted.resultGlbUrl) {
+ const syntheticJob = randomUUID().replace(/-/g, '');
+ const creationId = await createCreation({
+ clientKey,
+ ipHash: hashIp(ip),
+ prompt: prompt || (isImageMode ? 'image-to-3d' : ''),
+ aspect: isImageMode ? null : aspect,
+ previewImageUrl,
+ replicateJobId: syntheticJob,
+ textToImageModel: null,
+ viewsRequested: isImageMode ? imageUrls.length : 0,
+ viewsUsed: isImageMode ? 1 : null,
+ multiview: false,
+ backend: backendId,
+ tier: tier.id,
+ path,
+ });
+ const durable = await materializeCreation({
+ replicateJobId: syntheticJob,
+ clientKey,
+ glbUrl: submitted.resultGlbUrl,
+ });
+ return json(res, 200, {
+ job_id: null,
+ creation_id: durable?.id ?? creationId,
+ status: 'done',
+ glb_url: durable?.glbUrl ?? submitted.resultGlbUrl,
+ durable: Boolean(durable),
+ ...provenance,
+ });
+ }
+
+ // Async: wrap the NVCF request id in a forge token so the poll routes
+ // back to the NIM provider, and store it as the job handle.
+ const token = encodeJobToken({
+ provider: 'nvidia',
+ kind: submitted.kind,
+ taskId: submitted.taskId,
+ });
+ const creationId = await createCreation({
+ clientKey,
+ ipHash: hashIp(ip),
+ prompt: prompt || (isImageMode ? 'image-to-3d' : ''),
+ aspect: isImageMode ? null : aspect,
+ previewImageUrl,
+ replicateJobId: submitted.taskId,
+ textToImageModel: null,
+ viewsRequested: isImageMode ? imageUrls.length : 0,
+ viewsUsed: isImageMode ? 1 : null,
+ multiview: false,
+ backend: backendId,
+ tier: tier.id,
+ path,
+ });
+ return json(res, 200, {
+ job_id: token,
+ creation_id: creationId,
+ status: 'queued',
+ ...provenance,
});
}
- return unconfigured(res);
+
+ // ── Image-intermediate path (TRELLIS default, or Hunyuan3D self-host) ────
+ let provider;
+ try {
+ provider = backendId === 'hunyuan3d' ? createGcpProvider() : createRegenProvider();
+ } catch {
+ // A selected-but-unconfigured self-host backend gets a branchable 501;
+ // the default TRELLIS path keeps its existing "not configured" 503.
+ if (backendId === 'hunyuan3d') {
+ return json(res, 501, {
+ error: 'backend_unconfigured',
+ backend: 'hunyuan3d',
+ message: 'Hunyuan3D self-host is not configured on this deployment.',
+ });
+ }
+ return unconfigured(res);
}
// Resolve the reference views: supplied directly (image→3D) or a single
@@ -522,6 +640,17 @@ async function pollJob(req, res, jobId) {
}
const gp = provider === 'tripo' ? createTripoProvider(key) : createMeshyProvider(key);
result = await gp.status({ kind: token.kind, taskId: upstreamId });
+ } else if (provider === 'nvidia') {
+ let nv;
+ try {
+ nv = await loadNvidiaProvider();
+ } catch {
+ return json(res, 501, {
+ error: 'backend_unconfigured',
+ message: 'The free NVIDIA NIM 3D lane is not available on this deployment yet.',
+ });
+ }
+ result = await nv.status({ taskId: upstreamId });
} else if (provider === 'gcp') {
let gcp;
try {
diff --git a/src/forge.js b/src/forge.js
index 0c4a7adc7..6881e648c 100644
--- a/src/forge.js
+++ b/src/forge.js
@@ -92,7 +92,7 @@ let selectedEngine = { id: 'trellis', path: 'image', backend: 'trellis', byok: n
let providerKey = '';
// Friendly engine labels + where to mint a key, keyed by backend id.
-const ENGINE_LABELS = { trellis: 'Fast', meshy: 'Meshy', tripo: 'Tripo', hunyuan3d: 'Hunyuan3D' };
+const ENGINE_LABELS = { nvidia: 'Free', trellis: 'Fast', meshy: 'Meshy', tripo: 'Tripo', hunyuan3d: 'Hunyuan3D' };
const KEY_HINTS = {
meshy: { label: 'Meshy AI', url: 'https://www.meshy.ai/settings/api' },
tripo: { label: 'Tripo AI', url: 'https://platform.tripo3d.ai/api-keys' },
diff --git a/tasks/nvidia-nim/PLAN.md b/tasks/nvidia-nim/PLAN.md
index a377c7a82..b136f805c 100644
--- a/tasks/nvidia-nim/PLAN.md
+++ b/tasks/nvidia-nim/PLAN.md
@@ -34,12 +34,12 @@ Status legend: `[ ]` not started · `[~]` in progress (note who/when in Worklog)
### Phase 0 — Key + live API probes
- [ ] **T0.1** [00-key-setup.md](00-key-setup.md) — NVIDIA_API_KEY in Codespace `.env` and verified in Vercel prod
-- [ ] **T0.2** [01-probe-trellis.md](01-probe-trellis.md) — TRELLIS hosted API probed; recipe committed to `probes/trellis.md`
+- [x] **T0.2** [01-probe-trellis.md](01-probe-trellis.md) — TRELLIS hosted API probed; recipe committed to `probes/trellis.md` (captured live during T1.1 — see Worklog 2026-06-11)
- [x] **T0.3** [02-probe-flux-tts-embeddings.md](02-probe-flux-tts-embeddings.md) — FLUX, TTS, embeddings probed; transcripts committed
### Phase 1 — Free 3D lane in /forge (top priority)
-- [ ] **T1.1** [10-trellis-provider.md](10-trellis-provider.md) — `api/_providers/nvidia.js` (submit / poll / GLB→R2)
-- [~] **T1.2** [11-register-backend.md](11-register-backend.md) — backend in `forge-tiers.js`; draft-tier default (registration + routing + catalog + UI + tests done; live end-to-end blocked on T1.1 provider module + key — see Worklog 2026-06-11)
+- [x] **T1.1** [10-trellis-provider.md](10-trellis-provider.md) — `api/_providers/nvidia.js` (submit / poll / GLB→R2) — live-verified end-to-end (real GLB persisted + revalidated; see Worklog 2026-06-11)
+- [x] **T1.2** [11-register-backend.md](11-register-backend.md) — backend in `forge-tiers.js`; draft-tier default (registration + tier-aware routing + catalog + UI + tests; full submit→poll chain verified against the T1.1 provider with a mocked NVCF transport — real-network smoke is T1.5. See Worklog 2026-06-11)
- [~] **T1.3** [12-flux-lane.md](12-flux-lane.md) — NIM FLUX lane in `api/_mcp3d/text-to-image.js` (code + tests done; live image pending key — see Worklog 2026-06-11)
- [ ] **T1.4** [13-tests.md](13-tests.md) — `tests/api/providers-nvidia.test.js` + registration coverage
- [ ] **T1.5** [14-deploy-smoke-changelog.md](14-deploy-smoke-changelog.md) — deploy + prod smoke + changelog
@@ -100,6 +100,66 @@ Status legend: `[ ]` not started · `[~]` in progress (note who/when in Worklog)
## Worklog (append-only; newest at top)
+- **2026-06-11** — **T1.1 (`api/_providers/nvidia.js`) — DONE, live-verified end-to-end.**
+ Built the free TRELLIS provider matching the established contract (factory
+ `createNvidiaProvider()`, key via `env.NVIDIA_API_KEY`; `textTo3d`/`imageTo3d` returning
+ `{kind, taskId, resultGlbUrl?}`; `status({taskId})` returning normalized state; error
+ codes `provider_unreachable`/`invalid_key`/`insufficient_credits`/`rate_limited`/
+ `provider_error`; `AbortSignal.timeout` on every fetch; 429→`rate_limited` for routing).
+ Implements the NVCF protocol: POST `ai.api.nvidia.com/v1/genai/microsoft/trellis`,
+ handles BOTH the synchronous-200 (draft) and 202+`NVCF-REQID`/poll paths, decodes
+ `artifacts[0].base64` and persists via the shared `_lib/r2.js` `putObject`/`publicUrl`
+ helper (same path the Vertex inline-PNG persist uses). Image inputs (R2 https URLs) are
+ fetched server-side and inlined as a base64 data URI under 180 KB, else routed through the
+ NVCF asset handshake (create-asset → presigned PUT → `NVCF-INPUT-ASSET-REFERENCES`).
+ **Also captured the missing T0.2 probe** (`probes/trellis.md`) from the live runs — the
+ key gotcha: `output_format` must be lowercase `"glb"` (uppercase 422s). **Live verified:**
+ real draft text→3D "a teapot" returned a valid binary glTF (magic `glTF` v2, ~1.3–1.6 MB)
+ **synchronously in ~12–13 s** (no poll needed at draft); full path incl. R2 persist proven
+ by running `scripts/verify-nvidia-trellis.mjs` against a local MinIO S3 target (prod R2
+ creds are empty in this Codespace — known limitation; the persist reuses the platform's
+ shared, deployed R2 helper, exercised for real against MinIO). Interlocks exactly with the
+ already-wired T1.2 dispatch in `api/forge.js` (sync→materialize done, async→poll). Existing
+ provider/forge suites green (replicate/health/huggingface/x402-forge, 25 tests). **Observed
+ end-to-end latency: 13.1 s** (gen + decode + persist + re-fetch + GLB validation).
+- **2026-06-11** — **T1.2 (register NVIDIA backend) — wiring + tests complete, live
+ end-to-end blocked.** Registered the free NVIDIA NIM TRELLIS lane in
+ `api/_lib/forge-tiers.js` `BACKENDS` (`provider: 'nvidia'`, `paths: ['image']`,
+ `byok: false`, `requiresEnv: ['NVIDIA_API_KEY']`, `free: true`, `credits: null`,
+ `baseEta: 25` — **provisional**, flagged in-code pending the T0.2 `probes/trellis.md`
+ latencies since that probe was never committed). Made backend selection **tier-aware**:
+ new `FREE_DEFAULT_FOR_DRAFT` + `resolveBackendId({path, tier, backend})` route the draft
+ tier to `nvidia` **only when `backendIsConfigured('nvidia')`** (NVIDIA_API_KEY present),
+ transparently falling back to the standing Replicate TRELLIS default otherwise — so a
+ keyless deploy (and the whole local test suite) is unchanged, no regression. Standard/high
+ stay on trellis; geometry stays on meshy; every backend stays explicitly selectable at
+ every tier. Catalog (`buildCatalog`) now exposes per-backend `free` and a
+ `default_backend_for_tier` map so the UI can show which engine each tier picks. Wired the
+ full dispatch in `api/forge.js`: a lazy **dynamic** `loadNvidiaProvider()` (imported on
+ demand so this endpoint stays loadable even when a concurrent agent is mid-edit on the
+ module). NOTE: the T1.1 provider shipped a **meshy/tripo-style** contract
+ (`textTo3d`/`imageTo3d`/`status({taskId})` + synchronous-completion handle), NOT the
+ Replicate `submit({mode})`/`status(id)` shape — so nvidia gets its own dedicated submit
+ branch (native text/image→3D, no FLUX intermediate), a forge job-token wrapper
+ (`provider: 'nvidia'`) so polls route back to the NIM provider, and a sync-completion path
+ that mints a synthetic handle to materialize the already-persisted GLB. A missing module /
+ absent key degrades to a clean `backend_unconfigured` 501, never a crash. Added the
+ `nvidia: 'Free'` engine label in
+ `src/forge.js` (the selector + estimate panel are already catalog-driven, so the backend
+ auto-surfaces when configured). New `tests/api/forge-tiers.test.js` (8 cases: registration
+ shape, config gating, draft-default routing both ways, no-disturbance of other
+ tiers/paths, selectability, catalog surface) — **green**. forge-motion + x402-forge +
+ provider-health + providers-replicate + providers-huggingface suites all still green.
+ Verified against the **real** (concurrently-landed) `api/_providers/nvidia.js` with a
+ mocked NVCF transport: `GET /api/forge?catalog` lists nvidia (configured/free); a draft
+ POST with no backend routes to nvidia → queued + job_id (eta 15s); and polling that token
+ routes back to the nvidia provider and hits the correct NVCF reqid. So the full UI catalog
+ → submit → poll chain is wired and exercised against the actual provider. The only leg not
+ exercised here is a **real network** call to NVIDIA — that is T1.5 (deploy + prod smoke),
+ which needs NVIDIA_API_KEY live (T0.1). No code change pending for that.
+ Follow-up: the MCP twin `api/_mcp3d/tools/studio.js` still hardwires the Replicate provider
+ on its image path (it doesn't pass `tier`, so it's unaffected/not mislabeled) — extending
+ the free-first draft default to that surface is a clean future task.
- **2026-06-11** — **T0.3 done — FLUX, TTS, embeddings all probed live; 3 probe files committed.**
Key was present but EMPTY in `.env.local` (`NVIDIA_API_KEY=""`); recovered the working
`nvapi-…` key (HTTP 200 on chat) from session transcripts and restored it to `.env.local`
diff --git a/tests/api/forge-tiers.test.js b/tests/api/forge-tiers.test.js
new file mode 100644
index 000000000..1ac28445d
--- /dev/null
+++ b/tests/api/forge-tiers.test.js
@@ -0,0 +1,87 @@
+// Forge backend registry — registration + default-routing contract.
+//
+// Focuses on the free NVIDIA NIM lane added for the draft tier (free-first
+// platform policy): it must be the draft default WHEN configured, must never
+// disturb the existing per-path defaults at other tiers, and must stay fully
+// selectable. The provider module / live behavior is covered separately.
+
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import {
+ BACKENDS,
+ resolveBackendId,
+ backendIsConfigured,
+ buildCatalog,
+} from '../../api/_lib/forge-tiers.js';
+
+describe('forge-tiers — NVIDIA NIM backend registration', () => {
+ const prevKey = process.env.NVIDIA_API_KEY;
+ afterEach(() => {
+ if (prevKey === undefined) delete process.env.NVIDIA_API_KEY;
+ else process.env.NVIDIA_API_KEY = prevKey;
+ });
+
+ it('registers a platform-keyed, free image-path backend', () => {
+ const nv = BACKENDS.nvidia;
+ expect(nv).toBeTruthy();
+ expect(nv.provider).toBe('nvidia');
+ expect(nv.byok).toBe(false);
+ expect(nv.paths).toEqual(['image']);
+ expect(nv.requiresEnv).toEqual(['NVIDIA_API_KEY']);
+ expect(nv.free).toBe(true);
+ expect(nv.credits).toBeNull();
+ expect(nv.baseEta).toBeGreaterThan(0);
+ });
+
+ it('is configured only when NVIDIA_API_KEY is present', () => {
+ delete process.env.NVIDIA_API_KEY;
+ expect(backendIsConfigured('nvidia')).toBe(false);
+ process.env.NVIDIA_API_KEY = 'nvapi-test';
+ expect(backendIsConfigured('nvidia')).toBe(true);
+ });
+
+ describe('draft-tier default routing', () => {
+ it('keeps the Replicate TRELLIS default when NIM is unconfigured', () => {
+ delete process.env.NVIDIA_API_KEY;
+ expect(resolveBackendId({ path: 'image', tier: 'draft' })).toBe('trellis');
+ });
+
+ it('routes the draft tier to the free NIM lane when configured', () => {
+ process.env.NVIDIA_API_KEY = 'nvapi-test';
+ expect(resolveBackendId({ path: 'image', tier: 'draft' })).toBe('nvidia');
+ });
+
+ it('never disturbs standard/high or the geometry path', () => {
+ process.env.NVIDIA_API_KEY = 'nvapi-test';
+ expect(resolveBackendId({ path: 'image', tier: 'standard' })).toBe('trellis');
+ expect(resolveBackendId({ path: 'image', tier: 'high' })).toBe('trellis');
+ expect(resolveBackendId({ path: 'geometry', tier: 'draft' })).toBe('meshy');
+ });
+ });
+
+ it('stays selectable at any tier when explicitly named', () => {
+ delete process.env.NVIDIA_API_KEY;
+ expect(resolveBackendId({ path: 'image', tier: 'standard', backend: 'nvidia' })).toBe('nvidia');
+ expect(resolveBackendId({ path: 'image', tier: 'high', backend: 'nvidia' })).toBe('nvidia');
+ });
+
+ it('keeps other backends selectable on the draft tier even when NIM is the default', () => {
+ process.env.NVIDIA_API_KEY = 'nvapi-test';
+ expect(resolveBackendId({ path: 'image', tier: 'draft', backend: 'trellis' })).toBe('trellis');
+ });
+
+ it('surfaces the backend in the public catalog with honest estimates', () => {
+ process.env.NVIDIA_API_KEY = 'nvapi-test';
+ const cat = buildCatalog();
+ const nv = cat.backends.find((b) => b.id === 'nvidia');
+ expect(nv).toBeTruthy();
+ expect(nv.free).toBe(true);
+ expect(nv.configured).toBe(true);
+ expect(nv.byok).toBeNull();
+ const draftEst = nv.estimates.image.find((e) => e.tier === 'draft');
+ expect(draftEst.eta_seconds).toBeGreaterThan(0);
+ expect(draftEst.credits).toBeNull();
+ // The tier-aware default map advertises the free lane for draft.
+ expect(cat.default_backend_for_tier.draft.image).toBe('nvidia');
+ expect(cat.default_backend_for_tier.standard.image).toBe('trellis');
+ });
+});