Skip to content

feat: validate custom NVIDIA NIM model availability - #492

Open
jyje wants to merge 2 commits into
langchain-ai:mainfrom
jyje:feat/nvidia-model-availability-validation
Open

feat: validate custom NVIDIA NIM model availability#492
jyje wants to merge 2 commits into
langchain-ai:mainfrom
jyje:feat/nvidia-model-availability-validation

Conversation

@jyje

@jyje jyje commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Validate selected models against a custom NVIDIA_BASE_URL NIM-compatible endpoint before inference starts.
  • Treat a model missing from that endpoint's /models response as unavailable.
  • Preserve inference when credentials are missing, the lookup fails, or the default NVIDIA hosted endpoint is used.

Why

A custom NVIDIA NIM deployment exposes the models actually loaded by that endpoint. Checking its model catalogue before inference gives users an actionable error instead of waiting for the first inference request to fail.

The default NVIDIA hosted endpoint remains non-authoritative for this check, so its catalogue cannot block inference without stronger entitlement guarantees.

Validation

  • pnpm run format:check
  • pnpm run lint:check
  • pnpm test
    • 174 test files passed, 2 skipped
    • 2,330 tests passed, 3 skipped
  • Fresh live GitHub Actions verification after conflict resolution: NVIDIA availability contract
    • verified PR head: d94ed3cd78dcd74ac2d290b9db97a796917fcc2c
    • 2 cases queried the live NVIDIA /v1/models endpoint
    • 3 cases deterministically verified non-blocking fallback behavior

Live verification cases

Case Input Network behavior Expected output Actual output
Positive model=nvidia/nemotron-3-super-120b-a12b, credential present, baseUrlIsCustom=true Live GET https://integrate.api.nvidia.com/v1/models { status: "available" } available
Negative model=openwiki-live-verification-nonexistent-model, credential present, baseUrlIsCustom=true Live GET https://integrate.api.nvidia.com/v1/models { status: "unavailable" } unavailable
No credential selected model, no API key, baseUrlIsCustom=true No request { status: "unknown" } unknown
Hosted default selected model, placeholder key, baseUrlIsCustom=false Fetch was configured to fail if called, proving no request was made { status: "unknown" } unknown
Lookup failure selected model, placeholder key, baseUrlIsCustom=true Injected fetch rejects with Error("offline") { status: "unknown" } unknown

The positive and negative cases intentionally mark the reachable NVIDIA service as NIM-compatible to exercise the custom-endpoint adapter. Production use of the built-in hosted endpoint sets baseUrlIsCustom=false; the hosted-default case verifies that this path remains non-authoritative and does not issue a catalogue request.

Quoted directly from the successful Actions log:

pr_head_sha=d94ed3cd78dcd74ac2d290b9db97a796917fcc2c
verification_sha=167804f283f08bddcb31c2a65f0f047233e75d5f
provider=nvidia
endpoint_mode=custom-nim-compatible
selected_model=nvidia/nemotron-3-super-120b-a12b
credential_present=true
case=positive provider=nvidia model=nvidia/nemotron-3-super-120b-a12b status=available
case=negative provider=nvidia model=openwiki-live-verification-nonexistent-model status=unavailable
case=no-credential provider=nvidia status=unknown
case=hosted-default provider=nvidia status=unknown
case=lookup-failure provider=nvidia status=unknown
Test Files 1 passed (1)
Tests 5 passed (5)

Reviewer reproduction

From a checkout of this PR branch, install dependencies and run the focused offline suite:

pnpm install --frozen-lockfile
pnpm vitest run test/model-availability.test.ts --reporter=verbose

To exercise the behavior against a custom NVIDIA NIM deployment, configure the provider with the API root that exposes /models:

export OPENWIKI_PROVIDER=nvidia
export NVIDIA_API_KEY="<your-NIM-api-key>"
export NVIDIA_BASE_URL="https://<your-NIM-host>/v1"

# Pick an ID returned by the same endpoint.
export OPENWIKI_MODEL_ID="<served-model-id>"

curl -fsS "${NVIDIA_BASE_URL%/}/models" \
  -H "Authorization: Bearer ${NVIDIA_API_KEY}"

pnpm dev -- --debug -p "Reply with OK."

Expected positive behavior: the selected model appears in data[].id, availability resolves to available, and the run proceeds to inference.

To verify the early unavailable-model error:

OPENWIKI_MODEL_ID="openwiki-review-nonexistent-model" \
  pnpm dev -- --debug -p "This request should not reach inference."

Expected negative behavior: OpenWiki stops before inference and reports that NVIDIA NIM does not make the selected model available. If the catalogue request cannot be completed, validation returns unknown and preserves the existing inference path.

The temporary live-verification workflow and test file are not included in this PR branch.

Related issue

This is the NVIDIA provider follow-up for #490 and reuses the shared availability contract introduced in #491.

Feedback is very welcome - please feel free to suggest changes or point out anything I may have missed.

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ade29ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openwiki Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jyje
jyje marked this pull request as ready for review August 14, 2026 00:28
jyje and others added 2 commits August 29, 2026 16:43
`unavailable` aborts the run before inference with no override, so every
inconclusive catalogue lookup that resolves to it is a total blocker. Four
paths could reach it without evidence that the model cannot be invoked.

- Derive "custom endpoint" by comparing the resolved base URL against the
  provider's built-in default rather than testing whether the env var is
  set. Pinning `NVIDIA_BASE_URL` to the documented hosted endpoint made the
  public hosted catalogue authoritative over entitlement it does not model.
- Treat an empty `data` array as `unknown`. A proxied gateway that hides its
  catalogue from a key without list scope still serves inference.
- Bound the lookup with a 5s `AbortSignal.timeout`. The request now targets
  user-supplied infrastructure, where a stalled host held every run for
  undici's 300s default.
- Build the catalogue URL from `pathname` so a base URL carrying a query
  string keeps its last path segment, and fall back to `unknown` if the URL
  cannot be resolved at all.

Also surface the availability reason in the thrown error, which previously
blamed credentials for a model simply not loaded on the endpoint.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@jyje
jyje force-pushed the feat/nvidia-model-availability-validation branch from cb1d2e9 to ade29ca Compare August 29, 2026 07:46
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