Skip to content

BE gratis: add NVIDIA NIM as a provider - #20

Open
KailasMahavarkar wants to merge 1 commit into
mainfrom
f-BE-gratis-add-nvidia-nim-provider
Open

BE gratis: add NVIDIA NIM as a provider#20
KailasMahavarkar wants to merge 1 commit into
mainfrom
f-BE-gratis-add-nvidia-nim-provider

Conversation

@KailasMahavarkar

Copy link
Copy Markdown
Contributor

Adds NVIDIA NIM (build.nvidia.com) as a provider, routed through litellm's native nvidia_nim integration. 80 chat models join the market. Follows the existing provider contract exactly - fetch_* / build_*_market_stats / is_*_model / strip_*_prefix, and no rows at all without a key.

The prefix is nim/, not nvidia/

This is the load-bearing decision. NVIDIA is an author on OpenRouter, which really serves nvidia/nemotron-3-super-120b-a12b. A nvidia/ route prefix cannot be told apart from those ids.

I shipped nvidia/ first and the live catalogue caught it:

GET /v1/models  →  90 rows starting "nvidia/"   but NIM only has 80 chat models
                   ────────────────────────────
                   10 of them were OpenRouter models absorbed into the wrong provider

Consequences had it stayed: duplicate market rows, the provider filter claiming OpenRouter's models as NIM's, and resolve_model() sending an OpenRouter model to NIM, where it does not exist. Checked all 57 OpenRouter author segments — nvidia/ was the only collision, and nim/ collides with none. After the change:

nim/ rows    : 80   ← NIM's chat catalogue
nvidia/ rows : 10   ← OpenRouter's NVIDIA-authored models, correctly left alone

Both the specific case and the general rule are now pinned by tests.

Two more things specific to this catalogue

It is mixed modality. /v1/models lists embedders, rerankers, OCR, speech and diffusion models beside the chat ones — 22 of 102. None can serve a chat completion, so they are filtered at fetch rather than left for the availability prober to find one wasted call at a time.

102 listed  →  80 chat models kept
dropped: baai/bge-m3 · nvidia/embed-qa-4 · nvidia/nemoretriever-parse
         google/deplot · nvidia/ai-synthetic-video-detector · …

Its listing endpoint is public, unlike every other provider's — it returns 200 with no key. Kept gated on NVIDIA_NIM_API_KEY anyway: a deployment that cannot call these models must not advertise them.

Honesty notes

Field Value Why
is_free true Free by allocation, like Cloudflare Workers AI. A personal account has free credits; exhaustion surfaces as a quota error, which availability.py classifies transient — so running out hides the models rather than deleting them
ctx 32,768 NIM publishes no per-model window. A documented conservative floor, deliberately not the 128k most of these support
tps null NVIDIA publishes no throughput. Absent, not estimated
author from the id NIM ids name their author, so rows say who built the model, not only who serves it
tools true No per-model flag exists; matches what Groq and Cerebras already assume. Consistent rather than quietly different

Author labels were added to authors.py for the families that title-case badly (ai21labs → "AI21", 01-ai → "01.AI", nv-mistralai → "NVIDIA + Mistral").

Changes

File Intent
backend/providers/nvidia.py new - the provider
backend/providers/registry.py nim/ added to the prefix contract
backend/main.py resolve_model branch → nvidia_nim/<slug>; joins the rankings gather
backend/providers/models.py joins the unified catalogue
backend/providers/authors.py NIM author labels
src/config/providers.ts registered; nvapi-... key hint
globals.css, provider-avatar.tsx --color-provider-nvidia, both themes
src/app/layout.tsx, chat-empty-state.tsx provider count derived, not hardcoded
test_nvidia.py (new), test_registry.py, config.test.ts 22 tests

The hardcoded "7 providers" in the page metadata and the chat empty state had survived two provider additions. Both now count the registry and the loaded market instead.

Verification

backend    uv run pytest -q     174 passed  (was 154)
frontend   bun run test         118 passed  (was 116)
lint       0 errors             types  0 errors in src/     build  ✓ 8/8 pages

Live, against a server replaying the real captured catalogue from integrate.api.nvidia.com:

no NVIDIA_NIM_API_KEY   → 0 rows                    (no-key contract holds)
with key                → 80 of 102 kept            (22 non-chat filtered)
                          61 sized, 19 params=None  (no fabricated sizes)
                          5 flagged reasoning
                          authors: 01.AI · AI21 · AI Singapore · BigCode · Meta
full backend boot       → 525 models total
                          nim/ 80  ·  nvidia/ 10 (OpenRouter's, untouched)

The prefix collision was found by that live run, not by a test — the test came after. Worth knowing if you add another provider whose name is also an OpenRouter author.

Routes through litellm's native nvidia_nim provider (base
https://integrate.api.nvidia.com/v1, key NVIDIA_NIM_API_KEY), following the
same shape as every other provider module: fetch, build stats, is_/strip_
prefix helpers, and no rows at all without a key.

Three things are specific to this catalogue.

The prefix is `nim/`, not `nvidia/`. NVIDIA is an AUTHOR on OpenRouter, which
serves ids like nvidia/nemotron-3-super-120b-a12b. A `nvidia/` route prefix was
indistinguishable from those: the first live run returned 90 "NVIDIA" models
when NIM only has 80, because ten OpenRouter rows had been absorbed into the
wrong provider - and resolve_model would then have sent an OpenRouter model to
NIM, where it does not exist. `nim/` collides with none of OpenRouter's 57
author segments.

The catalogue is mixed modality. /v1/models lists embedders, rerankers, OCR,
speech and diffusion models next to the chat ones; 22 of 102. Those cannot
serve a chat completion, so they are filtered out here rather than left for the
availability prober to discover one wasted call at a time.

NIM's listing endpoint needs no key, unlike every other provider's. It is still
gated on NVIDIA_NIM_API_KEY: a deployment that cannot call these models must
not advertise them.

Model ids carry their author, so rows report who BUILT the model rather than
only who serves it. Context is a documented conservative floor - NIM publishes
no per-model window, and claiming one we have not verified is the kind of
confident-looking fiction this codebase keeps deleting.

Also: the "7 providers" line in the page metadata and the chat empty state was
hardcoded and had survived two provider additions. Both now count the registry
and the loaded market.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant