NVIDIA NIM pass-through
The /nvidia_nim/{model_group}/... route relays a native NIM request through a model group from model_list. The path names the group, for example /nvidia_nim/doc-ocr/v1/infer, and the body goes unchanged to the deployment's api_base. This matters for object detection and OCR NIMs, whose payload carries no model field, so the unified endpoints cannot route them. Through this route they still get virtual key checks, model access checks and spend logging, and the gateway's routing and fallbacks apply across the group's deployments.
A real-world scenario
A logistics team runs an OCR NIM on two GPU nodes and reads shipping labels from a mobile app. The payload is an image with no model name. The platform team registers both nodes as deployments of one model group doc-ocr, and the app posts to /nvidia_nim/doc-ocr/v1/infer with a virtual key. The gateway balances across the nodes, falls back when one is down, and every label scan is attributed to the app's key.
Before you start
Register a model group whose deployments all use nvidia_nim/ models.
model_list:
- model_name: doc-ocr
spanway_params:
model: nvidia_nim/nvidia/nemoretriever-ocr-v1
api_base: http://nim-node-1.internal:8000
api_key: os.environ/NVIDIA_NIM_API_KEY
- model_name: doc-ocr
spanway_params:
model: nvidia_nim/nvidia/nemoretriever-ocr-v1
api_base: http://nim-node-2.internal:8000
api_key: os.environ/NVIDIA_NIM_API_KEY
Steps
-
Register the deployments. Open
/ui/models-and-endpoints, on the Add Model tab pick Nvidia Nim under Provider, enter the model, give it the public namedoc-ocrunder Model Mappings, set API Base to the node address and click Add Model. Repeat for the second node with the same public name. Or add the config above. -
Issue a virtual key on
/ui/api-keyswith + Create New Key, then Create Key, and grant it thedoc-ocrmodel. -
Send the native NIM request through the gateway.
curl -X POST http://localhost:4000/nvidia_nim/doc-ocr/v1/infer \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"input": [{"type": "image_url", "url": "data:image/png;base64,iVBORw0KGgo..."}]}' -
Open
/ui/logsand click the newest row to see the request, the deployment that served it and the key.
Expected result
The NIM's own response, with its status code and headers. Streaming is streamed through as it arrives.
{"data": [{"index": 0, "bounding_boxes": [{"label": "table", "x": 12, "y": 40}]}]}
The spend log row carries the key, team, user and the deployment that served the call. The routing headers on the response say which node was picked.
Errors
| Status | Message | What it means and how to fix it |
|---|---|---|
401 | Authentication Error, Invalid proxy server token passed | The virtual key is missing, wrong, expired or blocked. |
403 | Key/team denied access to passthrough route /nvidia_nim/... | The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team. |
400 | no NVIDIA NIM model group in the path; call /nvidia_nim/{model_group}/v1/infer with a model group from your model_list whose deployments all use nvidia_nim/ models | The path does not start with a registered group, or the group mixes providers. Fix the path or the group. |
401 | A message saying the key cannot access the model | The key is not granted the model group. Add it under the key's models. |
| Any other | The NIM's own error body | The NIM refused the request. The message is returned unchanged. |
Related
Pass-through endpoints lists every built-in route. Routing decision headers explain how to read which deployment served a call, and the NVIDIA NIM provider page covers the unified integration.