Skip to main content

LlamaIndex LLMs Integration: NVIDIA NIM for LLMs

The llama-index-llms-nvidia package contains LlamaIndex integrations for building applications with NVIDIA NIM. With the NVIDIA LLM connector, you can develop LLM-powered systems using NVIDIA AI Foundation models.

NVIDIA NIM for LLM supports models across domains like chat, reward, and reasoning, from the community as well as from NVIDIA. Each model is optimized by NVIDIA to deliver the best performance on NVIDIA-accelerated infrastructure and is packaged as a NIM, an easy-to-use, prebuilt container that deploys anywhere using a single command on NVIDIA accelerated infrastructure. At their core, NIM for LLMs are containers that provide interactive APIs for running inference on an AI Model.

NVIDIA-hosted deployments are available on the NVIDIA API catalog to test each NIM. After you explore, you can download NIM for LLMs from the API catalog, which is included with the NVIDIA AI Enterprise license. The ability to run models on-premises or in your own cloud gives your enterprise ownership of your customizations and full control of your IP and AI application.

Use this documentation to learn how to install the llama-index-llms-nvidia package and use it to connect to, and generate content from, compatible LLM models.

Install the Package

To install the llama-index-llms-nvidia package, run the following code.

pip install llama-index-llms-nvidia

Access the NVIDIA API Catalog

To get access to the NVIDIA API Catalog, do the following:

  1. Create a free account on the NVIDIA API Catalog and log in.

  2. Click your profile icon, and then click API Keys. The API Keys page appears.

  3. Click Generate API Key. The Generate API Key window appears.

  4. Click Generate Key. You should see API Key Granted, and your key appears.

  5. Copy and save the key as NVIDIA_API_KEY.

  6. To verify your key, use the following code.

    import getpass
    import os
    
    if os.environ.get("NVIDIA_API_KEY", "").startswith("nvapi-"):
        print("Valid NVIDIA_API_KEY already in environment. Delete to reset")
    else:
        nvapi_key = getpass.getpass("NVAPI Key (starts with nvapi-): ")
        assert nvapi_key.startswith(
            "nvapi-"
        ), f"{nvapi_key[:5]}... is not a valid key"
        os.environ["NVIDIA_API_KEY"] = nvapi_key
    

You can now use your key to access endpoints on the NVIDIA API Catalog.

Work with the API Catalog

The following example chats with the default LLM.

from llama_index.llms.nvidia import NVIDIA
from llama_index.core.llms import ChatMessage, MessageRole

# Use the default model
llm = NVIDIA()

messages = [
    ChatMessage(
        role=MessageRole.SYSTEM, content=("You are a helpful assistant.")
    ),
    ChatMessage(
        role=MessageRole.USER,
        content=("What are the most popular house pets in North America?"),
    ),
]

llm.chat(messages)

For models that are not included in the CHAT_MODEL_TABLE, you must explicitly specify whether the model supports chat endpoints. Set the is_chat_model parameter as described following:

  • False – Use the /completions endpoint. This is the default value.
  • True – Use the /chat/completions endpoint.

The following example chats with the Llama-3.3-Nemotron-Super-49B-v1 LLM.

from llama_index.llms.nvidia import NVIDIA
from llama_index.core.llms import ChatMessage, MessageRole

# Use a specific model
llm = NVIDIA(
    model="nvidia/llama-3.3-nemotron-super-49b-v1", is_chat_model=True
)

messages = [
    ChatMessage(
        role=MessageRole.SYSTEM, content=("You are a helpful assistant.")
    ),
    ChatMessage(
        role=MessageRole.USER,
        content=("What are the most popular house pets in North America?"),
    ),
]

llm.chat(messages)

Self-host with NVIDIA NIM for LLMs

When you are ready to deploy your AI application, you can self-host models with NVIDIA NIM for LLMs. For more information, refer to NVIDIA AI Enterprise.

The following example code connects to a locally-hosted LLM.

from llama_index.llms.nvidia import NVIDIA

# connect to an chat NIM running at localhost:8080
llm = NVIDIA(base_url="http://localhost:8080/v1")

Related Topics

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_llms_nvidia-0.6.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_nvidia-0.6.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_nvidia-0.6.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_nvidia-0.6.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_nvidia-0.6.0.tar.gz
Algorithm Hash digest
SHA256 231d566f1ac9597ef173bf319bb331d8f1e73cef71b45945c8e791641de95313
MD5 fccf52855b8dbcc3c82f9ef4fc23127f
BLAKE2b-256 860e81f50f4dd14e000a258fd5dc927825157632be8671c3e9c8661260fb3500

See more details on using hashes here.

File details

Details for the file llama_index_llms_nvidia-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_nvidia-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_nvidia-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59d660e761e5bf68a4357c6182dbf3f36d020248d9ba6d11be578a992b0f5415
MD5 f18c37dbd07e39e4c64733163cf2ea4b
BLAKE2b-256 a32e8f8084ca7201ccdb37dcf047807d74b90ad0515fc2f6b2f6a1bcb3686b31

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page