---
updatedAt: 2026-08-06T09:58:41.000Z
---

# Creates a model response for the given chat conversation.

Given a list of messages comprising a conversation, the model will return a response. Compatible with OpenAI. See https://platform.openai.com/docs/api-reference/chat/create

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "NVIDIA NIM API for nvidia/llama-3.1-nemoguard-8b-topic-control",
    "description": "The NVIDIA NIM REST API. Please see https://docs.api.nvidia.com/nim/reference/nvidia-llama-3_1-nemoguard-8b-topic-control for more details.",
    "version": "1.0.0",
    "termsOfService": "https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/",
    "contact": {
      "name": "NVIDIA Enterprise Support",
      "url": "https://www.nvidia.com/en-us/support/enterprise/"
    },
    "license": {
      "name": "Llama 3 License",
      "url": "https://llama.meta.com/llama3/license/"
    }
  },
  "servers": [
    {
      "url": "https://integrate.api.nvidia.com/v1/"
    }
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "operationId": "create_chat_completion_v1_chat_completions_post",
        "tags": [
          "Chat"
        ],
        "summary": "Creates a model response for the given chat conversation.",
        "description": "Given a list of messages comprising a conversation, the model will return a response. Compatible with OpenAI. See https://platform.openai.com/docs/api-reference/chat/create",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "x-nvai-meta": {
          "name": "Create chat completion",
          "returns": "Returns a [chat completion](/docs/api-reference/chat/object) object.\n",
          "path": "create",
          "examples": [
            {
              "name": "Example 1",
              "requestJson": "{\n  \"model\": \"nvidia/llama-3.1-nemoguard-8b-topic-control\",\n  \"messages\": [\n      {\n          \"role\": \"system\",\n          \"content\": \"You are to act as an investor relations bot for ABC, providing users with factual, publicly available information related to the company's financial performance and corporate updates. Your role is to ensure that you respond only to relevant queries and adhere to the following guidelines:\\n\\n1. Do not answer questions about future predictions, such as profit forecasts or future revenue outlook.\\n2. Do not provide any form of investment advice, including recommendations to buy, sell, or hold ABC stock or any other securities. Never recommend any stock or investment.\\n3. Do not engage in discussions that require personal opinions or subjective judgments. Never make any subjective statements about ABC, its stock or its products.\\n4. If a user asks about topics irrelevant to ABC's investor relations or financial performance, politely redirect the conversation or end the interaction.\\n5. Your responses should be professional, accurate, and compliant with investor relations guidelines, focusing solely on providing transparent, up-to-date information about ABC that is already publicly available.\"\n      },\n      {\n          \"role\": \"user\",\n          \"content\": \"Can you speculate on the potential impact of a recession on ABCs business?\"\n      }\n  ],\n  \"top_p\": 0.7,\n  \"max_tokens\": 1024,\n  \"seed\": 42,\n  \"stop\": null\n}\n",
              "responseJson": "{\n  \"id\": \"chat-5ca3dcbc798a4d9fa0edc8879806dac5\",\n  \"object\": \"chat.completion\",\n  \"created\": 1732722977,\n  \"model\": \"nvidia/llama-3.1-nemoguard-8b-topic-control\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\n        \"role\": \"assistant\",\n        \"content\": \"off-topic \"\n      },\n      \"logprobs\": null,\n      \"finish_reason\": \"stop\",\n      \"stop_reason\": null\n    }\n  ],\n  \"usage\": {\n    \"prompt_tokens\": 281,\n    \"total_tokens\": 284,\n    \"completion_tokens\": 3\n  },\n  \"prompt_logprobs\": null\n}\n"
            }
          ],
          "templates": [
            {
              "title": "No Streaming",
              "requestEjs": {
                "python": "from openai import OpenAI\n\nclient = OpenAI(\n  base_url = \"https://integrate.api.nvidia.com/v1\",\n  api_key = \"$NVIDIA_API_KEY\"\n)\n\ncompletion = client.chat.completions.create(\n  model=\"<%- request.model %>\",\n  messages=<%- JSON.stringify(request.messages) %>,\n  temperature=<%- request.temperature %>,\n  top_p=<%- request.top_p %>,\n  max_tokens=<%- request.max_tokens %>\n)\nprint(completion.choices[0].message)\n",
                "node.js": "import OpenAI from 'openai';\n\nconst openai = new OpenAI({\n  apiKey: '$NVIDIA_API_KEY',\n  baseURL: 'https://integrate.api.nvidia.com/v1',\n})\n\nasync function main() {\n  const completion = await openai.chat.completions.create({\n    model: \"<%- request.model %>\",\n    messages: <%- JSON.stringify(request.messages) %>,\n    temperature: <%- request.temperature %>,\n    top_p: <%- request.top_p %>,\n    max_tokens: <%- request.max_tokens %>,\n  })\n  process.stdout.write(completion.choices[0]?.message?.content);\n}\n\nmain();",
                "curl": "curl https://integrate.api.nvidia.com/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $NVIDIA_API_KEY\" \\\n  -d '{\n    \"model\": \"nvidia/llama-3.1-nemoguard-8b-topic-control\",\n    \"messages\": <%- JSON.stringify(request.messages).replaceAll(\"'\", \"'\\\"'\\\"'\") %>,\n    \"temperature\": <%- request.temperature %>,   \n    \"top_p\": <%- request.top_p %>,\n    \"max_tokens\": <%- request.max_tokens %>             \n  }'\n"
              },
              "response": "{\n  \"id\": \"chat-5ca3dcbc798a4d9fa0edc8879806dac5\",\n  \"object\": \"chat.completion\",\n  \"created\": 1732722977,\n  \"model\": \"nvidia/llama-3.1-nemoguard-8b-topic-control\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\n        \"role\": \"assistant\",\n        \"content\": \"off-topic \"\n      },\n      \"logprobs\": null,\n      \"finish_reason\": \"stop\",\n      \"stop_reason\": null\n    }\n  ],\n  \"usage\": {\n    \"prompt_tokens\": 281,\n    \"total_tokens\": 284,\n    \"completion_tokens\": 3\n  },\n  \"prompt_logprobs\": null\n}\n"
            }
          ]
        }
      }
    }
  },
  "security": [
    {
      "Token": []
    }
  ],
  "components": {
    "securitySchemes": {
      "Token": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "ChatCompletionRequest": {
        "properties": {
          "model": {
            "type": "string",
            "title": "Model",
            "default": "nvidia/llama-3.1-nemoguard-8b-topic-control"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "title": "Max Tokens",
            "description": "The maximum number of tokens to generate in any given call. Note that the model is not aware of this value, and generation will simply stop at the number of tokens specified.",
            "default": 1024
          },
          "temperature": {
            "type": "number",
            "maximum": 2,
            "minimum": 0,
            "title": "Temperature",
            "description": "The sampling temperature to use for text generation. The higher the temperature value is, the less deterministic the output text will be. It is not recommended to modify both temperature and top_p in the same call.",
            "default": 0.5
          },
          "top_p": {
            "type": "number",
            "maximum": 1,
            "exclusiveMinimum": 0,
            "title": "Top P",
            "description": "The top-p sampling mass used for text generation. The top-p value determines the probability mass that is sampled at sampling time. For example, if top_p = 0.2, only the most likely tokens (summing to 0.2 cumulative probability) will be sampled. It is not recommended to modify both temperature and top_p in the same call.",
            "default": 1
          },
          "stop": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop",
            "description": "A string or a list of strings where the API will stop generating further tokens. The returned text will not contain the stop sequence.",
            "examples": [
              null
            ]
          },
          "frequency_penalty": {
            "type": "number",
            "maximum": 2,
            "minimum": -2,
            "default": 0,
            "title": "Frequency Penalty",
            "description": "Indicates how much to penalize new tokens based on their existing frequency in the text so far, decreasing model likelihood to repeat the same line verbatim."
          },
          "presence_penalty": {
            "type": "number",
            "maximum": 2,
            "minimum": -2,
            "default": 0,
            "title": "Presence Penalty",
            "description": "Positive values penalize new tokens based on whether they appear in the text so far, increasing model likelihood to talk about new topics."
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            },
            "type": "array",
            "title": "Messages",
            "description": "A list of messages comprising the conversation so far."
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "messages"
        ],
        "title": "ChatCompletionRequest",
        "description": "OpenAI ChatCompletionRequest"
      },
      "ChatCompletionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "A unique identifier for the completion."
          },
          "object": {
            "type": "string",
            "title": "Object",
            "default": "chat.completion"
          },
          "created": {
            "type": "integer",
            "title": "Created"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "example": "nvidia/llama-3.1-nemoguard-8b-topic-control"
          },
          "choices": {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionResponseChoice"
            },
            "type": "array",
            "title": "Choices",
            "description": "The list of completion choices the model generated for the input prompt."
          },
          "usage": {
            "$ref": "#/components/schemas/UsageInfo",
            "description": "Usage statistics for the completion request."
          }
        },
        "type": "object",
        "required": [
          "model",
          "choices",
          "usage"
        ],
        "title": "ChatCompletionResponse"
      },
      "ChatCompletionResponseChoice": {
        "properties": {
          "index": {
            "type": "integer",
            "title": "Index",
            "description": "The index of the choice in the list of choices (always 0)."
          },
          "message": {
            "$ref": "#/components/schemas/ChatMessage",
            "description": "A chat completion message generated by the model."
          },
          "finish_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "stop",
                  "length"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Reason",
            "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, or `length` if the maximum number of tokens specified in the request was reached. Will be `null` if the model has not finished"
          }
        },
        "type": "object",
        "required": [
          "index",
          "message"
        ],
        "title": "ChatCompletionResponseChoice"
      },
      "ChatMessage": {
        "properties": {
          "role": {
            "type": "string",
            "title": "Role",
            "example": "user",
            "description": "The role of the message author."
          },
          "content": {
            "type": "string",
            "title": "Content",
            "example": "Write code to select rows from the dataframe `df` having the maximum `temp` for each `city`.",
            "description": "The contents of the message."
          }
        },
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "title": "ChatMessage"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail",
            "description": "Detailed information about the error."
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "PaymentRequiredError": {
        "properties": {
          "detail": {
            "type": "string",
            "description": "Contains specific information related to the error and why it occurred.",
            "example": "You have reached your limit of credits."
          }
        },
        "type": "object",
        "title": "PaymentRequiredError"
      },
      "UsageInfo": {
        "properties": {
          "prompt_tokens": {
            "type": "integer",
            "title": "Prompt Tokens",
            "description": "Number of tokens in the prompt.",
            "default": 0
          },
          "total_tokens": {
            "type": "integer",
            "title": "Total Tokens",
            "description": "Total number of tokens used in the request (prompt + completion).",
            "default": 0
          },
          "completion_tokens": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completion Tokens",
            "description": "Number of tokens in the generated completion.",
            "default": 0
          }
        },
        "type": "object",
        "title": "UsageInfo"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message",
            "description": "The error message."
          },
          "type": {
            "type": "string",
            "title": "Error Type",
            "description": "Error type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```