NVIDIA NIM API tutorial: from zero to your first call
The short version
- Sign up at build.nvidia.com, no card needed.
- Open any model page and click Get API Key. Keys start with
nvapi-. - POST to the base URL below with that key as a Bearer token.
POST https://integrate.api.nvidia.com/v1/chat/completions
Base URL https://integrate.api.nvidia.com/v1. OpenAI-compatible.
When the free credits run out, the same models stay reachable here:
POST https://dreamprompting.com/api/v1/chat/completions
Free key, no card, automatic failover across providers.
NVIDIA NIM is one of the fastest ways to try large open models without renting a GPU, and getting a key takes about a minute. This tutorial walks the whole path: creating the key, sending a first request with curl, doing the same from Python and Node, turning on streaming, and handling the three errors that actually show up in practice. It ends with the part most tutorials skip, which is what to do when the free credits are gone.
Step 1: get a free NVIDIA NIM API key
Go to build.nvidia.com and create an account with an email address. No payment method is requested. New accounts receive a limited pool of free inference credits, which is enough to evaluate models properly but not enough to run a product on.
Once you are signed in, open any model in the catalog. Each model page has a Get API Key button that generates a personal key on the spot. The key looks like nvapi-... and works across the whole catalog, not just the model whose page you generated it from. Copy it somewhere safe, because the console will not show it again in full.
Treat the key like a password. It is a bearer credential: anyone holding it can spend your credits. Keep it in an environment variable, never in client-side JavaScript or a committed file.
Step 2: your first request with curl
NIM speaks the OpenAI chat completions format, so there is nothing NVIDIA-specific in the request body beyond the model id. Export your key and send this:
export NVIDIA_API_KEY="nvapi-..."
curl https://integrate.api.nvidia.com/v1/chat/completions \
-H "Authorization: Bearer $NVIDIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta/llama-3.3-70b-instruct",
"messages": [
{"role": "user", "content": "Explain NVIDIA NIM in one sentence."}
]
}'
A successful call returns the standard OpenAI response shape, with the text at choices[0].message.content. If you want to see what else you can pin, the catalog is one request away:
curl https://integrate.api.nvidia.com/v1/models \
-H "Authorization: Bearer $NVIDIA_API_KEY"
That currently returns 102 model ids from 25 different vendors, not only NVIDIA's own. Meta, Google, Mistral, DeepSeek, Microsoft and OpenAI's open-weight models are all served through the same endpoint. There is a full breakdown of the NIM catalog if you want to see what is worth pinning.
Step 3: the same call from Python
Because the endpoint is OpenAI-compatible, you do not need an NVIDIA SDK. Install the official openai package and change two arguments:
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.3-70b-instruct",
messages=[
{"role": "user", "content": "Give me three uses for a NIM model."}
],
temperature=0.2,
)
print(resp.choices[0].message.content)
That is the entire integration. Every other parameter you already know, including temperature, max_tokens, stop and tools, behaves the way it does against OpenAI.
Step 4: the same call from Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://integrate.api.nvidia.com/v1",
apiKey: process.env.NVIDIA_API_KEY,
});
const resp = await client.chat.completions.create({
model: "meta/llama-3.3-70b-instruct",
messages: [{ role: "user", content: "Explain NIM to a backend engineer." }],
});
console.log(resp.choices[0].message.content);
Step 5: turn on streaming
Streaming matters more on NIM than on most endpoints, because the large models take a noticeable moment to produce the first token. Streaming does not make the model faster, but it makes the wait visible instead of blank:
stream = client.chat.completions.create(
model="meta/llama-3.3-70b-instruct",
messages=[{"role": "user", "content": "Write a haiku about GPUs."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
Step 6: the three errors you will actually hit
Most NIM integration problems are one of these three, and each has a different fix:
| Status | What it means | Fix |
|---|---|---|
401 |
Key missing, malformed or revoked. | Check the header is Authorization: Bearer nvapi-..., not x-api-key. |
402 / 403 |
Free credits exhausted. | Add billing, or route the same models through a pooled gateway (below). |
429 / 503 |
Rate limited, or the model is cold and capacity is spinning up. | Retry with backoff, pin a smaller model, or fail over to another provider. |
The 503 is the one that surprises people. It is not usually an outage. Large models are not kept warm indefinitely, so the first request after an idle period pays a cold start that can run to several seconds. A retry a moment later often succeeds against the very same model.
Step 7: what to do when the credits run out
This is where most NIM tutorials stop, and it is the part that decides whether your project survives. NVIDIA's free credits are an evaluation allowance, not a free tier. Once they are spent you have three options: add a payment method to NVIDIA, self-host a NIM container (which needs an NVIDIA AI Enterprise license plus your own GPU), or reach the same models through a gateway that pools free tiers from several providers.
The third option costs you a one-line change, because the request body is identical. Swap the base URL and the key:
client = OpenAI(
base_url="https://dreamprompting.com/api/v1", # was integrate.api.nvidia.com/v1
api_key="YOUR_FREE_KEY", # from /account, no card
)
resp = client.chat.completions.create(
model="nvidia/meta/llama-3.3-70b-instruct", # nvidia/ prefix pins NIM
messages=[{"role": "user", "content": "Still works."}],
)
Pinning nvidia/ routes to NIM specifically. Sending "model": "auto" instead lets the gateway pick a healthy provider, which is the practical answer to cold starts: if a NIM model is slow or unavailable, the call fails over rather than timing out. Quotas are 100 requests per minute per IP, plus a rolling 24 hour account quota of 5,000 requests and 500,000 tokens.
Frequently asked questions
- How do I get a free NVIDIA NIM API key?
- Sign up at build.nvidia.com, open any model page, and click Get API Key. No card is required. The key starts with
nvapi-and works across the entire catalog. - What is the NVIDIA NIM API base URL?
https://integrate.api.nvidia.com/v1, with chat requests going to/v1/chat/completions. See the endpoint reference for the full picture.- Is NVIDIA NIM really free?
- Free to start, not free to stay. New accounts get a credit pool and the hosted endpoint is paid after that. Self-hosting needs an AI Enterprise license and a GPU.
- Can I use the OpenAI SDK with NIM?
- Yes. Change
base_urlandapi_keyand nothing else. That is the whole point of an OpenAI-compatible endpoint. - Can I run these models on my own GPU?
- Many of them, if you have the VRAM. Check what your card holds with the VRAM calculator, or see which GPUs run a given model.
Start building
You now have a key, a working request, streaming, and a plan for when the credits run out. Browse the live model catalog to pick an id, or read the full API reference for every supported parameter. If you would rather not write code yet, try the models in the hosted chat first.