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
docs(nvidia-nim): probe FLUX, Magpie TTS, embeddings + reranker (T0.3)
nirholasbb3734a8f0e3
diff --git a/tasks/nvidia-nim/PLAN.md b/tasks/nvidia-nim/PLAN.mdindex 34ed87882..a377c7a82 100644--- a/tasks/nvidia-nim/PLAN.md+++ b/tasks/nvidia-nim/PLAN.md@@ -35,11 +35,11 @@ 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`-- [ ] **T0.3** [02-probe-flux-tts-embeddings.md](02-probe-flux-tts-embeddings.md) — FLUX, TTS, embeddings probed; transcripts committed+- [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+- [~] **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)- [~] **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,29 @@ Status legend: `[ ]` not started · `[~]` in progress (note who/when in Worklog)## Worklog (append-only; newest at top)+- **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`+ (gitignored). **This unblocks the T1.3 entry below** — its endpoint/recipe is now confirmed+ live and `probes/flux.md` exists. Findings:+ • **FLUX** (`probes/flux.md`) ✅ free, synchronous (no poll). `POST+ ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-schnell` (steps ≤4) / `…/flux.1-dev`+ (steps ≥5). Output is **JPEG** base64 in `artifacts[0].base64` (not PNG — persist as+ jpeg). width/height are a discrete enum (768…1344). ~1.5 s schnell, ~8 s dev. Bad key → **403**.+ • **TTS** (`probes/tts.md`) ⚠️ **gRPC-only, no REST.** Magpie hosted as NVCF gRPC fn+ `877104f7-…` on `grpc.nvcf.nvidia.com:443` (function-id in metadata). Produced a real+ 4.37 s WAV via `nvidia-riva-client`. 9 langs, ~14 voices × emotion variants. **Phase 2 is+ feasible** but T2.1 must add a `@grpc/grpc-js` + Riva-proto client (~half-day) — recorded+ the build plan in the probe file. `/v1/audio/speech` and all `genai` REST paths 404.+ • **Embeddings** (`probes/embeddings.md`) ✅ OpenAI-compatible at+ `integrate.api.nvidia.com/v1/embeddings`, `input_type:query|passage` **required** (400+ without). **Plan's model is EOL** (`llama-3.2-nv-embedqa-1b-v2` → 410, EOL 2026-05-18);+ use **`nvidia/nv-embedqa-e5-v5` (1024-dim)** or `llama-nemotron-embed-1b-v2` (2048-dim).+ Max **512 tokens/input**, batch ≥512 ok. Reranker `nvidia/rerank-qa-mistral-4b` live at+ `ai.api.nvidia.com/v1/retrieval/nvidia/reranking` (returns `rankings[{index,logit}]`).+ Several catalog-listed embed/rerank models 404 "Not found for account" (deploy-only).+ Phase 3 must tag vectors by embedder+dim (NIM 1024 ≠ OpenAI 1536 — never mix spaces).+ Scratch image/audio files verified then deleted; no key in any committed file.- **2026-06-11** — **T1.3 (NIM FLUX lane) — code + tests complete, live run blocked.**Added FLUX.1-schnell on NVIDIA NIM as the FIRST lane in `api/_mcp3d/text-to-image.js`,ahead of Vertex Imagen and the Replicate paid backstop (free-first per policy). Builtdiff --git a/tasks/nvidia-nim/probes/embeddings.md b/tasks/nvidia-nim/probes/embeddings.mdnew file mode 100644index 000000000..9cd988664--- /dev/null+++ b/tasks/nvidia-nim/probes/embeddings.md@@ -0,0 +1,143 @@+# Probe: NVIDIA NIM — Embeddings + Reranker (retrieval lane)++**Date:** 2026-06-11 · **Task:** T0.3 (Phase 0) · **Key:** `NVIDIA_API_KEY` (`nvapi-…`, redacted)++**Verdict:** ✅ **Embeddings + reranker both invocable on the hosted free tier.** Embeddings+are OpenAI-compatible at `integrate.api.nvidia.com/v1/embeddings` and **require** the extra+`input_type: "query"|"passage"` field (confirmed). Reranker is a separate non-OpenAI+endpoint on `ai.api.nvidia.com`. This unblocks Phase 3 (widget RAG).++> ⚠️ **EOL trap:** the model named in the plan, `nvidia/llama-3.2-nv-embedqa-1b-v2`, is+> **GONE** — `410 Gone, end of life 2026-05-18`. So is the reranker+> `nvidia/llama-3.2-nv-rerankqa-1b-v2` (410, same date). Use the live models below.++---++## Live embedding models (verified 200 on this account)++| model id | dim | notes |+|---------------------------------------|------|-------|+| `nvidia/nv-embedqa-e5-v5` | **1024** | E5 retrieval QA; fast (~0.45 s). **Recommended default** for widget RAG. |+| `nvidia/llama-nemotron-embed-1b-v2` | **2048** | Higher-dim successor to the EOL'd `llama-3.2-nv-embedqa-1b-v2`. ~0.6 s. |++**Listed in `/v1/models` but NOT invocable on this free account** (return+`404 … Not found for account …` — provisioned/deploy-only): `nvidia/embed-qa-4`,+`nvidia/nv-embedqa-mistral-7b-v2`, `snowflake/arctic-embed-l`. Don't build against these+without confirming provisioning. (`/v1/models` lists 120 ids; presence ≠ invocable.)++## Embeddings endpoint (OpenAI-compatible)++```+POST https://integrate.api.nvidia.com/v1/embeddings+Authorization: Bearer $NVIDIA_API_KEY+Content-Type: application/json+```++Request:+```json+{+ "model": "nvidia/nv-embedqa-e5-v5",+ "input": ["text one", "text two"],+ "input_type": "passage", // REQUIRED — "query" or "passage"+ "encoding_format": "float" // optional+}+```++Response (standard OpenAI shape):+```json+{+ "data": [{"index":0,"embedding":[0.01, ...]}, ...],+ "model": "nvidia/nv-embedqa-e5-v5",+ "usage": {"prompt_tokens": 22, "total_tokens": 22}+}+```++### `input_type` — confirmed mandatory (asymmetric models)+- Omitted → **400** `{"error":"'input_type' parameter is required for asymmetric models"}`.+- Must be exactly `"query"` or `"passage"` → invalid value (e.g. `"document"`) → **400**+ `Input should be 'query' or 'passage'`.+- **RAG contract:** embed corpus chunks with `input_type:"passage"` at ingest, embed the+ user's question with `input_type:"query"` at search time. Mismatching them degrades recall.++### Limits (probed empirically)+- **Max input length: 512 tokens per item.** A ~4000-word single input → **400**+ `Input length 4032 exceeds maximum allowed token size 512`. **Chunk to ≤512 tokens.**+- **Batch size:** 512 inputs per request returned 200 (`n=512`). 256 and 300 also fine. 512+ is comfortably enough for batched ingest; throttle for the free tier rather than maxing it.+- Vectors are **not** unit-normalized guaranteed — normalize client-side if your store needs it.++### Rate-limit headers+None on success — only `nvcf-reqid` / `nvcf-status: fulfilled`. Free tier is credit-metered;+expect 429 under load → treat as `rate_limited` and back off (same pattern as the other lanes).++---++## Reranker (separate endpoint — NOT OpenAI-shaped)++```+POST https://ai.api.nvidia.com/v1/retrieval/nvidia/reranking+Authorization: Bearer $NVIDIA_API_KEY+Content-Type: application/json+```++- **Live model on this account: `nvidia/rerank-qa-mistral-4b`** (HTTP 200, ~0.25 s).+ - Discovered via the endpoint's own error: posting an unknown model returns+ `Available models are: ['nvidia/rerank-qa-mistral-4b', 'nv-rerank-qa-mistral-4b:1']`.+ - `nvidia/nv-rerankqa-mistral-4b-v3` → `404 Not found for account` (deploy-only here).+ - The v2/3 `…/<model>/reranking` path style and `integrate…/v1/ranking` both 404 — use+ the `…/retrieval/nvidia/reranking` path above with the model in the body.++Request:+```json+{+ "model": "nvidia/rerank-qa-mistral-4b",+ "query": {"text": "What is the capital of France?"},+ "passages":[{"text":"Paris is the capital of France."},+ {"text":"Berlin is in Germany."},+ {"text":"The Eiffel Tower is a famous landmark in Paris."}]+}+```++Response — `rankings` sorted best-first, each pointing back to the input passage `index`+with a relevance `logit` (higher = more relevant; values are unbounded logits, not 0–1):+```json+{+ "rankings": [+ {"index": 0, "logit": 3.77},+ {"index": 2, "logit": -12.72},+ {"index": 1, "logit": -14.63}+ ]+}+```+- Use as a **post-retrieval reorder** in T3.2: pull top-N by embedding cosine, then rerank+ and keep top-k. `index` maps to your candidate array. No `input_type` field here.++---++## Reproduction (key redacted)++```bash+KEY="nvapi-…" # from .env.local / .env — NEVER commit the real value++# embeddings+curl -s https://integrate.api.nvidia.com/v1/embeddings \+ -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \+ -d '{"model":"nvidia/nv-embedqa-e5-v5","input":["Paris is the capital of France."],"input_type":"passage"}' \+ | python3 -c "import sys,json;v=json.load(sys.stdin)['data'][0]['embedding'];print('dim',len(v))" # -> dim 1024++# reranker+curl -s https://ai.api.nvidia.com/v1/retrieval/nvidia/reranking \+ -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \+ -d '{"model":"nvidia/rerank-qa-mistral-4b","query":{"text":"capital of France?"},+ "passages":[{"text":"Paris is the capital of France."},{"text":"Berlin is in Germany."}]}'+# -> {"rankings":[{"index":0,"logit":...},{"index":1,"logit":...}]}+```++## Impact on Phase 3 (T3.1–T3.3)+- Free primary embedder = **`nvidia/nv-embedqa-e5-v5` (1024-dim)**. **This is a different+ vector space and a different dimension from OpenAI** (`text-embedding-3-small` = 1536) —+ the plan's "tag every vector with embedder id + dim, never mix at query time" rule is+ mandatory: stored OpenAI rows can't be queried with NIM vectors and vice-versa.+- Chunk corpus to **≤512 tokens** before ingest (hard cap), batch ≤512 per call, throttle.+- Optional reranker stage available for free (`nvidia/rerank-qa-mistral-4b`) for T3.2's+ top-3 relevance bump — no extra provisioning needed.diff --git a/tasks/nvidia-nim/probes/flux.md b/tasks/nvidia-nim/probes/flux.mdnew file mode 100644index 000000000..faf40669c--- /dev/null+++ b/tasks/nvidia-nim/probes/flux.md@@ -0,0 +1,104 @@+# Probe: NVIDIA NIM — FLUX text→image (black-forest-labs)++**Date:** 2026-06-11 · **Task:** T0.3 (Phase 0) · **Key:** `NVIDIA_API_KEY` (`nvapi-…`, redacted below)++**Verdict:** ✅ **Fully invocable on the hosted free tier.** Synchronous JSON, no+202/poll, no NVCF asset handshake. Both `flux.1-schnell` and `flux.1-dev` work. This is a+drop-in free first lane for `api/_mcp3d/text-to-image.js` (T1.3).++---++## Endpoint++```+POST https://ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-schnell+POST https://ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-dev+```++- **Host is `ai.api.nvidia.com/v1/genai/…`, NOT `integrate.api.nvidia.com`.** The+ `integrate` host (used by the chat/OpenAI-compatible lanes) 404s for these models+ (`/v1/infer/black-forest-labs/flux.1-schnell` → `404 page not found`).+- Auth: `Authorization: Bearer $NVIDIA_API_KEY`+- `Content-Type: application/json`, `Accept: application/json`+- **Response is synchronous** — single request returns the image inline. `nvcf-status:+ fulfilled` header, no poll URL, no `NVCF-POLL-SECONDS`. (Unlike TRELLIS.)++## Request schema++| field | type | schnell | dev | notes |+|-------------|--------|-------------------------------|-------------------------------|-------|+| `prompt` | string | required | required | |+| `steps` | int | **1–4** (≤4 enforced) | **≥5** (≥5 enforced) | schnell is the 4-step distilled model |+| `cfg_scale` | float | accepted | accepted (used 3.5) | guidance scale |+| `width` | enum | one of the size set below | same | |+| `height` | enum | one of the size set below | same | |+| `seed` | int | accepted, echoed back | accepted, echoed back | deterministic |+| `samples` | int | **≤1** (1 image per call) | ≤1 | no batching |+| `mode` | string | accepted (`base`) | — | |++**Allowed `width`/`height` values (discrete enum, not free range):**+`768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344`.+Anything else → `422 literal_error`. (e.g. `720`, `2048` rejected.) `1024×1024` is the safe default.++## Response shape++```json+{+ "artifacts": [+ {+ "base64": "/9j/4AAQSkZJRgABAQ…", // JPEG bytes, base64+ "finishReason": "SUCCESS",+ "seed": 42+ }+ ]+}+```++- Image is **JPEG** (magic `ffd8ffe0`, JFIF), 3-channel RGB, at the requested size.+ Decoded & verified with PIL: `JPEG (1024, 1024) RGB`, ~70 KB for a 1024² schnell image.+- Field is `artifacts[0].base64` (raw base64, no `data:` prefix). `finishReason: SUCCESS`.+- **When persisting to R2 in T1.3, write it as `.jpg`/`image/jpeg`**, not PNG (the Replicate+ FLUX lane returns PNG — don't assume the same content-type).++## Observed latency (Codespace → NVIDIA)++| model | steps | size | wall time |+|-----------------|-------|-----------|-----------|+| flux.1-schnell | 4 | 1024×1024 | ~1.5 s |+| flux.1-dev | 50 | 1024×1024 | ~8.0 s |++schnell is the right pick for the interactive free lane; dev only if a quality tier wants it.++## Rate-limit headers++None observed. Response headers were just `date`, `content-type: application/json`,+`access-control-expose-headers: nvcf-reqid`, `nvcf-reqid: <uuid>`, `nvcf-status: fulfilled`.+No `x-ratelimit-*` / `retry-after` on success. Free tier is credit-metered; expect 429+under load (treat as `rate_limited` in the provider contract — same as TRELLIS).++## Error shapes (for normalized error mapping in T1.3)++- **403** bad/expired key → `{"status":403,"title":"Forbidden","detail":"Authorization failed"}`+ (note: **403**, not 401 → map to `invalid_key`).+- **422** schema violation → `{"detail":[{"type":"…","loc":["body","steps"],"msg":"…","input":…,"ctx":{…}}]}`+ (FastAPI-style validation array → map to `provider_error`, log `detail`).+- Expect **402** insufficient credits / **429** rate-limited under sustained use (not+ reproduced — credits available at probe time).++## Reproduction (key redacted)++```bash+KEY="nvapi-…" # from .env.local / .env (NEVER commit the real value)++curl -s https://ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-schnell \+ -H "Authorization: Bearer $KEY" \+ -H 'Content-Type: application/json' \+ -H 'Accept: application/json' \+ -d '{"prompt":"a red ceramic teapot on a wooden table",+ "width":1024,"height":1024,"steps":4,"seed":42}' \+ | python3 -c "import sys,json,base64;a=json.load(sys.stdin)['artifacts'][0];open('out.jpg','wb').write(base64.b64decode(a['base64']))"+# -> out.jpg : JPEG 1024x1024 RGB, ~70 KB (deleted after verification)+```++Verified: produced a real `out.jpg`, decodes as valid JPEG 1024×1024 RGB via PIL and+`file(1)`. Scratch files deleted.diff --git a/tasks/nvidia-nim/probes/tts.md b/tasks/nvidia-nim/probes/tts.mdnew file mode 100644index 000000000..0282ef088--- /dev/null+++ b/tasks/nvidia-nim/probes/tts.md@@ -0,0 +1,125 @@+# Probe: NVIDIA NIM — TTS (Magpie / Riva)++**Date:** 2026-06-11 · **Task:** T0.3 (Phase 0) · **Key:** `NVIDIA_API_KEY` (`nvapi-…`, redacted)++**Verdict:** ✅ **Invocable on the hosted free tier — but gRPC-only, NOT REST.** There is+**no** `/v1/audio/speech` or HTTP JSON endpoint for Magpie/Riva TTS (all 404). It's served+as an NVCF **gRPC** function over `grpc.nvcf.nvidia.com:443` with a `function-id` in the+call metadata. Produced a real 4.37 s WAV — works end to end. **Phase 2 (T2.1) is feasible**,+but the speak.js lane must speak gRPC, not fetch JSON. Effort + recipe below.++---++## What's hosted (NVCF function list for this account)++`GET https://api.nvcf.nvidia.com/v2/nvcf/functions` (Bearer key) → 164 functions. TTS/speech:++| function name | function-id | what |+|-------------------------------|----------------------------------------|------|+| `ai-magpie-tts-multilingual` | `877104f7-e885-42b9-8de8-f6e4c6303969` | **TTS, 9 languages** — use this |+| `ai-magpie-tts-zeroshot` | `55cf67bf-600f-4b04-8eac-12ed39537a08` | TTS voice-cloning (zero-shot, ref audio) |+| `ai-parakeet-ctc-riva` | `22164014-a6cc-4a6f-b048-f3a303e745bb` | ASR / speech-to-text (bonus, not needed for T2.1) |+| `ai-riva-translate-1_6b` / `-4b` | … | NMT translation |++> `function-id` is required as gRPC **metadata** on every call; it selects the model.++## Why REST is out++All of these 404 (verified): `integrate.api.nvidia.com/v1/audio/speech`,+`ai.api.nvidia.com/v1/genai/nvidia/magpie-tts-multilingual`,+`…/v1/audio/nvidia/magpie-tts-multilingual`. Hitting the gRPC host over plain HTTP+(`https://grpc.nvcf.nvidia.com/v1/…`) returns the gRPC tell:+`reason:"no function-id was passed in the metadata"`. So: **gRPC with NVCF metadata is the+only transport.** There is no NVIDIA-hosted REST proxy for it.++## Working recipe (verified — produced real audio)++Transport: **Riva gRPC over TLS** to `grpc.nvcf.nvidia.com:443`, metadata+`function-id: <id>` + `authorization: Bearer <key>`. Easiest client = `nvidia-riva-client`+(Python) — used here to prove it; the production lane (Node/Vercel) uses `@grpc/grpc-js`+with the Riva protos (see "Effort for T2.1").++```python+# pip install nvidia-riva-client+import os, wave, riva.client+auth = riva.client.Auth(+ use_ssl=True, uri="grpc.nvcf.nvidia.com:443",+ metadata_args=[["function-id", "877104f7-e885-42b9-8de8-f6e4c6303969"],+ ["authorization", "Bearer " + os.environ["NVIDIA_API_KEY"]]])+svc = riva.client.SpeechSynthesisService(auth)+resp = svc.synthesize(+ "Hello world. This is a NVIDIA Magpie text to speech probe.",+ voice_name="Magpie-Multilingual.EN-US.Sofia", # see voices below+ language_code="en-US",+ sample_rate_hz=44100,+ encoding=riva.client.AudioEncoding.LINEAR_PCM) # raw PCM little-endian s16+# resp.audio = raw PCM bytes; wrap in a WAV header (1ch, 16-bit) to play.+```++**Verified output:** `resp.audio` = 385,024 bytes → wrapped as mono/16-bit/44.1 kHz WAV =+**4.37 s, valid `RIFF WAVE PCM`** (`file(1)` + `wave` confirm). Other voices/langs also 200:+`Magpie-Multilingual.EN-US.Ray` (en-US), `Magpie-Multilingual.ES-US.Diego` (es-US), and the+bare `Magpie-Multilingual`. Scratch WAVs deleted.++## Request parameters++| param | value |+|------------------|-------|+| `text` | the utterance (also accepts SSML) |+| `voice_name` | `Magpie-Multilingual.<LANG>.<Name>[.<Emotion>]` — see below |+| `language_code` | one of the 9 below |+| `sample_rate_hz` | requested output rate; native model rate is **22050**, server resamples (44100 worked) |+| `encoding` | `LINEAR_PCM` (raw s16; wrap in WAV) — Riva also supports `OGGOPUS`, `ALAW`, `MULAW` |++**Streaming:** `SpeechSynthesisService.synthesize_online(...)` yields audio chunks for+low-latency playback (Riva supports streaming TTS) — useful if avatar speech wants+first-byte-fast streaming instead of buffering the whole clip.++## Voices & languages (from the live model config)++- **Languages (9):** `en-US, es-US, fr-FR, de-DE, zh-CN, vi-VN, it-IT, hi-IN, ja-JP`.+- **Voice names** (combine as `Magpie-Multilingual.<LANG>.<Voice>[.<Emotion>]`):+ `Mia, Jason, Aria, Leo, Sofia, Ray, Pascal, Diego, Isabela, Louise, HouZhen, Siwei,+ Long, Phung`.+- **Emotion suffixes** (per-voice subset): `Neutral, Calm, Angry, Happy, Sad, Fearful,+ Disgust, PleasantSurprised`. e.g. `Magpie-Multilingual.EN-US.Aria.Happy`.+- Model is `magpie_tts`, `multilingual: True`, native `sample_rate: 22050`,+ `is_zero_shot: False` (the zeroshot/cloning model is the separate `ai-magpie-tts-zeroshot` fn).++## Rate limits / errors++No rate-limit headers surfaced over gRPC. Free tier is credit-metered → expect gRPC+`RESOURCE_EXHAUSTED` / `UNAVAILABLE` under load (map to `rate_limited`),+`UNAUTHENTICATED` for a bad key. Bad voice/lang → `INVALID_ARGUMENT`.++---++## Phase 2 (T2.1) decision — feasible, gRPC client required++`api/tts/speak.js` is a Vercel **Node** function currently hard-wired to OpenAI's REST+`/v1/audio/speech`. NIM TTS cannot reuse that fetch path. To make NIM the free first lane:++1. **Add a gRPC client.** Vendor the Riva TTS protos (`riva_tts.proto` + `riva_audio.proto`+ from `github.com/nvidia-riva/common`) and call with `@grpc/grpc-js` (pure-JS, works in+ Vercel serverless — no native addon). Channel: `grpc.nvcf.nvidia.com:443` with TLS+ credentials; attach per-call metadata `function-id` + `authorization: Bearer $NVIDIA_API_KEY`.+ *(Alternative: shell out is not viable on Vercel; `nvidia-riva-client` is Python-only.)*+2. **Map existing voices.** Callers pass OpenAI-style names (`nova`, `shimmer`, …). Map to+ nearest Magpie voice, e.g. `nova → Magpie-Multilingual.EN-US.Aria`,+ `shimmer → …EN-US.Sofia`, `onyx → …EN-US.Ray`, default `…EN-US.Sofia`.+3. **Output handling.** Magpie returns raw PCM → either wrap a WAV header server-side+ (simple) or request `OGGOPUS` for smaller payloads. Set `x-tts-voice`/`x-tts-model`+ headers to what actually served (`magpie-tts-multilingual`).+4. **Fallback.** NIM first, OpenAI REST as the paid backstop, per-attempt timeout, fail+ over before any audio bytes stream. Mirror into+ `packages/avatar-agent-mcp/src/tools/speak.js`.++**Effort: moderate (~half a day).** The only real work is the grpc-js + proto plumbing+(one small `api/_lib/nim-tts.js` helper); voice mapping and fallback are mechanical. No+blocker — hosted TTS is real and free, just gRPC. Record this decision in the Worklog+before building T2.1.++## Reproduction summary (key redacted)+- List functions: `GET https://api.nvcf.nvidia.com/v2/nvcf/functions` (Bearer key).+- Synthesize: Python snippet above, or grpc-js against the same host/metadata.+- Verified: 4.37 s mono 16-bit 44.1 kHz WAV from Magpie multilingual. Scratch deleted.