NVIDIA NIM OpenAI-Compatible API: Base URL, Setup, Gotchas (2026)
Does NVIDIA NIM have an OpenAI-compatible API?
Yes. NVIDIA NIM for LLMs exposes an OpenAI-compatible inference API, so you can call it with the official OpenAI SDK by changing only the base URL, the API key and the model name. There are two ways to reach it: NVIDIA's hosted API catalog at https://integrate.api.nvidia.com/v1, and a self-hosted NIM container you run on your own GPUs, which serves the same style of API on port 8000 by default.
This guide covers both routes, the endpoints NIM supports, working Python and curl examples, and the differences that trip people up when they switch from OpenAI. Facts below come from NVIDIA's NIM for LLM and VLM documentation (API reference, quickstart and architecture pages) and the NVIDIA API catalog docs, checked on December 2, 2026.
Two ways to use NIM: hosted catalog vs. self-hosted container
|
|
Hosted API catalog |
Self-hosted NIM container |
|---|---|---|
|
Base URL |
|
|
|
Where it runs |
NVIDIA DGX Cloud |
Your GPUs (on-prem or cloud) |
|
Credentials |
NVIDIA Developer API key from build.nvidia.com ("Get API Key" on a model page) |
No key on requests in NVIDIA's quickstart examples; |
|
Models |
Whatever the catalog lists, from many vendors |
The model your container serves |
|
Best for |
Prototyping, trying models |
Production control, data residency, fixed GPU cost |
NVIDIA notes that select catalog models are also available as downloadable containers, supported with an NVIDIA AI Enterprise entitlement. The API shape is the same on both sides, so code written against the catalog moves to a self-hosted container by changing the base URL.
Endpoints NIM supports
According to NVIDIA's API reference, the container's inference engine (vLLM or SGLang, depending on the image) serves these endpoints:
|
Endpoint |
What it does |
|---|---|
|
|
Multi-turn chat with message history; supports streaming and tool calling |
|
|
Single-turn text completions |
|
|
OpenAI Responses API, plus |
|
|
Anthropic-compatible messages endpoint |
|
|
Lists the models currently loaded for inference |
|
|
Liveness and readiness probes |
NVIDIA's architecture page also lists /v1/embeddings for embedding generation. Paths that are not explicitly configured return 404 Not Found, which NVIDIA describes as secure by default. The hosted catalog's LLM endpoint is documented as POST /v1/chat/completions on https://integrate.api.nvidia.com.
Call the hosted NIM API with the OpenAI SDK
Get a key from a model page on build.nvidia.com, store it in an environment variable, and point the OpenAI client at the catalog:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://integrate.api.nvidia.com/v1",
api_key=os.environ["NVIDIA_API_KEY"],
)
resp = client.chat.completions.create(
model="meta/llama-3.1-8b-instruct",
messages=[{"role": "user", "content": "Explain GPU computing in two sentences."}],
max_tokens=200,
)
print(resp.choices[0].message.content)The model name uses the catalog's vendor/model form, for example meta/llama-3.1-8b-instruct or openai/gpt-oss-120b. Copy the exact ID from the model page rather than guessing.
Run and call a self-hosted NIM container
NVIDIA's quickstart runs a model-specific NIM like this:
export NIM_LLM_IMAGE=nvcr.io/nim/meta/llama-3.1-8b-instruct:2.1.7
docker run --gpus=all \
-e NGC_API_KEY=$NGC_API_KEY \
-e NIM_SERVED_MODEL_NAME="meta/llama-3.1-8b-instruct" \
-v "$LOCAL_NIM_CACHE:/opt/nim/.cache" \
-p 8000:8000 \
${NIM_LLM_IMAGE}Per the same page, NGC_API_KEY and Docker login are optional for eligible public-catalog NIMs; the key is required for Production Branch models (tags with a -pb suffix) and NIMs released before version 2.0.10. Mounting LOCAL_NIM_CACHE avoids re-downloading the model on restart.
Once the container is ready, find the served model name and send a request:
curl -s http://localhost:8000/v1/models
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "meta/llama-3.1-8b-instruct",
"messages": [{"role": "user", "content": "Hello!"}],
"max_tokens": 100}'From Python, use the same OpenAI client with base_url="http://localhost:8000/v1". The SDK expects a non-empty api_key, so pass a placeholder string if your deployment does not check keys.
Where NIM differs from OpenAI
"OpenAI-compatible" covers the request and response shape, not every feature. Watch for these differences:
- Model names. NIM uses the served model name (for model-specific NIMs, an ID like
meta/llama-3.1-8b-instruct, or whatever you set inNIM_SERVED_MODEL_NAME). OpenAI model IDs such asgpt-6.2-solwill not resolve. - Features depend on the engine. NVIDIA states that the bundled engine, vLLM or SGLang, determines which inference features are available, and some endpoints are vLLM-only (for example the
renderendpoints). - Extra response fields. Responses can include engine-specific fields such as vLLM's
system_fingerprintor SGLang'smatched_stop. NVIDIA advises clients to accept these without requiring them. - Tool calling needs configuration. NIM supports OpenAI-format tool calling on both backends, but the model and parser setup must support it.
- SGLang naming rule. On SGLang, do not include a colon in
NIM_SERVED_MODEL_NAME, because the colon separates the base model from a LoRA adapter name. - Security is your job when self-hosting. The quickstart requests carry no Authorization header. If the endpoint is reachable beyond localhost, put it behind a gateway or proxy that enforces keys, and use the proxy's TLS and CORS settings.
For a general checklist of what usually breaks when you swap providers, see OpenAI Compatibility Issues, and for base URL mistakes specifically, OpenAI-Compatible Base URL.
Quick verification checklist
GET /v1/modelsreturns the model ID you plan to use.- A non-streaming chat request returns
choices[0].message.content. - A streaming request (
"stream": true) ends withdata: [DONE]. /v1/health/readyreturns success before you route traffic (self-hosted).- Your client tolerates unknown response fields.
- Any tool-calling flow is tested against the exact model and engine you deploy.
Frequently asked questions
What is the NVIDIA NIM API base URL?
For NVIDIA's hosted API catalog it is https://integrate.api.nvidia.com/v1. For a self-hosted container it is your host on the mapped port, by default http://localhost:8000/v1.
Can I use the OpenAI Python SDK with NVIDIA NIM?
Yes. Set base_url to the NIM endpoint, pass your NVIDIA API key (or a placeholder for an unauthenticated local container) and use a model name NIM serves.
Does NVIDIA NIM support the Responses API?
NVIDIA's API reference lists POST /v1/responses along with retrieve and cancel endpoints, served by the container's inference engine.
How do I find the right model name for NIM?
Call GET /v1/models and use the id field. On the hosted catalog, copy the ID shown on the model page at build.nvidia.com.
Do I need an NGC API key to run NIM?
Not always. NVIDIA says it is optional for eligible public-catalog NIMs and required for Production Branch models and NIMs released before 2.0.10. Model sources such as Hugging Face may still need their own token.
The short version
NVIDIA NIM speaks the OpenAI API. Use https://integrate.api.nvidia.com/v1 with an NVIDIA API key for the hosted catalog, or run a NIM container and call http://<host>:8000/v1. Keep your OpenAI SDK code, change the base URL, key and model name, confirm the model with GET /v1/models, and test streaming and tool calling on the exact engine you deploy. For background on how OpenAI-compatible APIs work in general, read What Is an OpenAI-Compatible API?.