BE gratis: add NVIDIA NIM as a provider - #20
Open
KailasMahavarkar wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds NVIDIA NIM (build.nvidia.com) as a provider, routed through litellm's native
nvidia_nimintegration. 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/, notnvidia/This is the load-bearing decision. NVIDIA is an author on OpenRouter, which really serves
nvidia/nemotron-3-super-120b-a12b. Anvidia/route prefix cannot be told apart from those ids.I shipped
nvidia/first and the live catalogue caught it: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, andnim/collides with none. After the change: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/modelslists 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.Its listing endpoint is public, unlike every other provider's — it returns 200 with no key. Kept gated on
NVIDIA_NIM_API_KEYanyway: a deployment that cannot call these models must not advertise them.Honesty notes
is_freetrueavailability.pyclassifies transient — so running out hides the models rather than deleting themctxtpsnullauthortoolstrueAuthor labels were added to
authors.pyfor the families that title-case badly (ai21labs→ "AI21",01-ai→ "01.AI",nv-mistralai→ "NVIDIA + Mistral").Changes
backend/providers/nvidia.pybackend/providers/registry.pynim/added to the prefix contractbackend/main.pyresolve_modelbranch →nvidia_nim/<slug>; joins the rankings gatherbackend/providers/models.pybackend/providers/authors.pysrc/config/providers.tsnvapi-...key hintglobals.css,provider-avatar.tsx--color-provider-nvidia, both themessrc/app/layout.tsx,chat-empty-state.tsxtest_nvidia.py(new),test_registry.py,config.test.tsThe 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
Live, against a server replaying the real captured catalogue from
integrate.api.nvidia.com: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.