> This page is for version 2.0.4-pb6.
> For other versions, use one of these documentation indexes:
> - 2.1.6 (Latest) (default): https://docs.nvidia.com/nim/large-language-models/2.1.6/llms.txt
> - 2.1.5: https://docs.nvidia.com/nim/large-language-models/2.1.5/llms.txt
> - 2.1.4: https://docs.nvidia.com/nim/large-language-models/2.1.4/llms.txt
> - 2.0.13: https://docs.nvidia.com/nim/large-language-models/2.0.13/llms.txt
> - 2.0.12: https://docs.nvidia.com/nim/large-language-models/2.0.12/llms.txt
> - 2.0.11: https://docs.nvidia.com/nim/large-language-models/2.0.11/llms.txt
> - 2.0.10: https://docs.nvidia.com/nim/large-language-models/2.0.10/llms.txt
> - 2.0.9: https://docs.nvidia.com/nim/large-language-models/2.0.9/llms.txt
> - 2.0.8: https://docs.nvidia.com/nim/large-language-models/2.0.8/llms.txt
> - 2.0.4-pb6: https://docs.nvidia.com/nim/large-language-models/2.0.4-pb6/llms.txt
> - Archive: https://docs.nvidia.com/nim/large-language-models/archive/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/large-language-models/llms.txt.

# Quickstart

## How to Choose the Right Model Profile

NIM LLM automatically selects the most optimal model profile based on the detected hardware (for example, number of GPUs or GPU architecture). If you need to manually override this selection, you can specify the `NIM_MODEL_PROFILE` environment variable. For more information, refer to [Model Profiles](/nim/large-language-models/2.0.4-pb6/deployment/model-profiles-and-selection).

## Run NIM

Before running a NIM LLM container, make sure you have fulfilled all [prerequisites](/nim/large-language-models/2.0.4-pb6/get-started/prerequisites), and have followed the steps in the [installation](/nim/large-language-models/2.0.4-pb6/get-started/installation) and [configuration](/nim/large-language-models/2.0.4-pb6/get-started/configuration) steps. This includes setting your API keys, logging in to Docker, pulling the container image, and configuring your `LOCAL_NIM_CACHE`.

> **Tip**
>
> Mounting a local cache directory lets you avoid re-downloading the model on subsequent restarts. Refer to [Local Cache](/nim/large-language-models/2.0.4-pb6/get-started/configuration#configure-local-cache) for details.

#### Model-Specific NIM

Run the container using your NGC API Key to authenticate and download the model.

```bash
docker run --gpus=all \
  -e NGC_API_KEY=$NGC_API_KEY \
  -v "$LOCAL_NIM_CACHE:/opt/nim/.cache" \
  -p 8000:8000 \
  ${NIM_LLM_IMAGE}
```

#### Model-Free NIM

Run the container using your Hugging Face token to authenticate and download the model.

```bash
docker run --gpus=all \
  -e NIM_MODEL_PATH=$NIM_MODEL_PATH \
  -e HF_TOKEN=$HF_TOKEN \
  -v "$LOCAL_NIM_CACHE:/opt/nim/.cache" \
  -p 8000:8000 \
  ${NIM_LLM_MODEL_FREE_IMAGE}
```

> **Note**
>
> If you want to serve a pre-downloaded local model or a private cloud model instead of downloading one from Hugging Face, refer to [Model Downloads](/nim/large-language-models/2.0.4-pb6/deployment/model-download) for your workflow.

## Interact with the API

There are three main inference endpoints:

* **Chat Completions**: `/v1/chat/completions`
* **Text Completions**: `/v1/completions`
* **Responses**: `/v1/responses`

> **Tip**
>
> All three endpoints support [streaming](#streaming).

### Find the Model Name

Replace `<model-name>` in the examples below with the model name served by your NIM container. To find it, query the models endpoint:

```bash
curl -s http://localhost:8000/v1/models
```

The `id` field in the response is the model name to use in your requests. For model-specific NIMs, this matches the model identifier (for example, `meta/llama-3.1-8b-instruct`). For model-free NIMs, the name is derived from the container image.

> **Note**
>
> The model name is user-configurable by setting the `NIM_SERVED_MODEL_NAME`
> environment variable. For more information, refer to [Environment Variables](/nim/large-language-models/2.0.4-pb6/reference/environment-variables).

### Send a Chat Completion Request

Once the server is running, you can send a request to the chat completion endpoint:

```bash
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-name>",
    "messages": [
      {
        "role": "user",
        "content": "Hello! How are you?"
      }
    ],
    "max_tokens": 100
  }'
```

The expected response:

```json
{
  "id": "chatcmpl-87d0c4524fb6f1a4",
  "object": "chat.completion",
  "created": 1769635152,
  "model": "<model-name>",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'm functioning properly,",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "function_call": null,
        "tool_calls": [],
        "reasoning": null
      },
      "logprobs": null,
      "finish_reason": "length",
      "stop_reason": null,
      "token_ids": null
    }
  ],
  "service_tier": null,
  "system_fingerprint": null,
  "usage": {
    "prompt_tokens": 41,
    "total_tokens": 46,
    "completion_tokens": 5,
    "prompt_tokens_details": null
  },
  "prompt_logprobs": null,
  "prompt_token_ids": null,
  "kv_transfer_params": null
}
```

### Verify Health Endpoints

You can verify that the NIM container is running and ready to accept requests by checking its health endpoints. By default, these endpoints are served on port `8000`. If you set `NIM_HEALTH_PORT`, use that port instead.

#### Live Endpoint

Perform a liveness check to see if the server is running:

```bash
curl http://localhost:8000/v1/health/live
```

Example response:

```http
GET /v1/health/live HTTP/1.1
Host: localhost:8000
User-Agent: curl/7.81.0
Accept: */*

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Content-Type: application/json
Content-Length: 61
Connection: keep-alive
Cache-Control: no-store, no-cache, must-revalidate

{
  "object": "health.response",
  "message": "live",
  "status": "live"
}
```

#### Ready Endpoint

Perform a readiness check to see if the model is fully loaded and ready for inference:

```bash
curl http://localhost:8000/v1/health/ready
```

Example response:

```http
GET /v1/health/ready HTTP/1.1
Host: localhost:8000
User-Agent: curl/7.81.0
Accept: */*

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Content-Type: application/json
Content-Length: 63
Connection: keep-alive
Cache-Control: no-store, no-cache, must-revalidate

{
  "object": "health.response",
  "message": "ready",
  "status": "ready"
}
```

### Streaming

To receive responses incrementally as they are generated, you can enable streaming by adding `"stream": true` to your request payload. This is supported across the `/v1/chat/completions`, `/v1/completions`, and `/v1/responses` endpoints.

When streaming is enabled, the API returns a sequence of Server-Sent Events (SSE).

```bash
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-name>",
    "messages": [
      {
        "role": "user",
        "content": "Write a short poem about a robot."
      }
    ],
    "max_tokens": 100,
    "stream": true
  }'
```

The response will be streamed back in chunks, with each chunk containing a `data` JSON object. The stream terminates with a `data: [DONE]` message:

```text
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"meta/llama-3.1-8b-instruct","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}],"prompt_token_ids":null}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"meta/llama-3.1-8b-instruct","choices":[{"index":0,"delta":{"content":"In"},"logprobs":null,"finish_reason":null,"token_ids":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"meta/llama-3.1-8b-instruct","choices":[{"index":0,"delta":{"content":" cir"},"logprobs":null,"finish_reason":null,"token_ids":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"meta/llama-3.1-8b-instruct","choices":[{"index":0,"delta":{"content":"cuits"},"logprobs":null,"finish_reason":null,"token_ids":null}]}

...

data: [DONE]
```