---
updatedAt: 2026-08-06T10:00:17.000Z
---

# Request response from the model

Invokes inference using the model chat parameters. If uploading large images, this POST should be used in conjunction with the NVCF API which allows for the upload of large assets. 
You can find details on how to use NVCF Asset APIs here: https://docs.api.nvidia.com/cloud-functions/reference/createasset

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "NVIDIA NIM API for nvidia/ising-calibration-1.5-31b",
    "description": "The NVIDIA NIM REST API. Please see https://docs.api.nvidia.com/nim/reference/nvidia-ising-calibration-1.5-31b for more details.",
    "version": "1.0.0",
    "termsOfService": "https://nvidia.com/legal/terms-of-use",
    "contact": {
      "name": "NVIDIA Support",
      "url": "https://help.nvidia.com/"
    },
    "license": {
      "name": "NVIDIA Open Model License",
      "url": "https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/"
    }
  },
  "servers": [
    {
      "url": "https://integrate.api.nvidia.com/v1"
    }
  ],
  "tags": [
    {
      "name": "Multimodal API",
      "description": "This API performs inference using visual language understanding models"
    }
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "tags": [
          "Multimodal API"
        ],
        "summary": "Request response from the model",
        "description": "Invokes inference using the model chat parameters. If uploading large images, this POST should be used in conjunction with the NVCF API which allows for the upload of large assets. \nYou can find details on how to use NVCF Asset APIs here: https://docs.api.nvidia.com/cloud-functions/reference/createasset",
        "operationId": "invokeFunction",
        "parameters": [
          {
            "in": "header",
            "name": "NVCF-INPUT-ASSET-REFERENCES",
            "schema": {
              "type": "string",
              "maxLength": 370,
              "format": "uuid"
            },
            "required": false,
            "description": "String of asset IDs separated by commas. Data is uploaded to AWS S3 using NVCF Asset APIs and associated with these asset IDs.If the size of an image is more than 180KB, it needs to be uploaded to a presigned S3 URL bucket. The presigned URL allows for secure and temporary access to the S3 bucket for uploading the image. Once the asset is requested, an asset ID is generated for it. Please include this asset ID in this header and to use the uploaded image in a prompt, you need to refer to it using the following format:  `<img src=\"data:image/png;asset_id,{asset_id}\" />`."
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NIMLLMChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Invocation is fulfilled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionStreamResponse"
                }
              }
            }
          },
          "202": {
            "description": "Result is pending. Client should poll using the requestId.\n",
            "content": {
              "application/json": {
                "example": {},
                "schema": {}
              }
            },
            "headers": {
              "NVCF-REQID": {
                "description": "requestId required for pooling",
                "schema": {
                  "type": "string",
                  "format": "uuid",
                  "maxLength": 36
                }
              },
              "NVCF-STATUS": {
                "description": "Invocation status",
                "schema": {
                  "type": "string",
                  "format": "^[a-zA-Z-]{1,64}$",
                  "maxLength": 64
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, provided entity could not be processed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "type": "urn:nvcf-worker-service:problem-details:unprocessable-entity",
                  "title": "Unprocessable Entity",
                  "status": 422,
                  "detail": "string",
                  "instance": "/v2/nvcf/pexec/functions/e598bfc1-b058-41af-869d-556d3c7e1b48",
                  "requestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
                }
              }
            }
          },
          "500": {
            "description": "The invocation ended with an error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "type": "urn:nvcf-worker-service:problem-details:internal-server-error",
                  "title": "Internal Server Error",
                  "status": 500,
                  "detail": "string",
                  "instance": "/v2/nvcf/pexec/functions/e598bfc1-b058-41af-869d-556d3c7e1b48",
                  "requestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
                }
              }
            }
          }
        },
        "x-nvai-meta": {
          "name": "Create chat completion",
          "returns": "Returns a [chat completion](/docs/api-reference/chat/object) object, or a streamed sequence of [chat completion chunk](/docs/api-reference/chat/streaming) objects if the request is streamed.\n",
          "path": "create",
          "examples": [
            {
              "name": "Resonator Spectroscopy",
              "input": {
                "text": "I just ran a resonator spectroscopy measurement on my superconducting qubit chip. This plot shows the magnitude response as a function of probe frequency across a wide scan range. Can you tell me how many resonator dips are visible, whether the signal quality is good enough, and whether we can proceed with readout setup?",
                "images": [
                  "https://assets.ngc.nvidia.com/products/api-catalog/ising-calibration-1-35b-a3b/resonator_spectroscopy.png"
                ]
              },
              "output": {
                "text": "Two resonator dips are visible near 8370 MHz and 8630 MHz. The signal quality is excellent and the calibration can proceed to readout setup."
              },
              "requestJson": "{\n  \"model\": \"nvidia/ising-calibration-1.5-31b\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"https://assets.ngc.nvidia.com/products/api-catalog/ising-calibration-1-35b-a3b/resonator_spectroscopy.png\"\n          }\n        },\n        {\n          \"type\": \"text\",\n          \"text\": \"I just ran a resonator spectroscopy measurement on my superconducting qubit chip. This plot shows the magnitude response as a function of probe frequency across a wide scan range.\\n\\nCan you tell me:\\n1. How many resonator dips are visible, and at what frequencies?\\n2. Is the signal quality good enough to extract reliable resonator frequencies?\\n3. What is the overall calibration status — can we proceed with qubit readout setup?\"\n        }\n      ]\n    }\n  ],\n  \"max_tokens\": 32768,\n  \"temperature\": 0.2,\n  \"top_p\": 1.0,\n  \"stream\": true\n}\n",
              "responseJson": "{\n  \"id\": \"chatcmpl-955b91a98c2dae31\",\n  \"object\": \"chat.completion\",\n  \"created\": 1775613991,\n  \"model\": \"nvidia/ising-calibration-1.5-31b\",\n  \"choices\": [{\n    \"index\": 0,\n    \"message\": {\n      \"role\": \"assistant\",\n      \"content\": \"Based on the provided resonator spectroscopy plot, here is my analysis:\\n\\n**1. Number and Frequency of Resonator Dips**\\nThere are **two distinct resonator dips** clearly visible in the magnitude response.\\n*   The first dip is located at approximately **8370 MHz**.\\n*   The second dip is located at approximately **8630 MHz**.\\nThese sharp downward features indicate the resonant frequencies where the probe signal is absorbed or coupled into the resonators.\\n\\n**2. Signal Quality and Reliability**\\nThe signal quality is **excellent** for extracting reliable frequencies.\\n*   **High Contrast:** The dips are very deep (dropping from a baseline of ~0.16 to ~0.07), providing a high signal-to-noise ratio.\\n*   **Low Noise:** The baseline signal is relatively flat with minor fluctuations, making the resonance features stand out sharply.\\n*   **Well-Defined Shape:** The Lorentzian-like shape of the dips is clear, allowing for precise fitting to determine the center frequency and linewidth.\\n\\n**3. Calibration Status and Next Steps**\\nThe overall calibration status is **successful**.\\n*   The presence of two clear, well-separated resonances indicates that the readout chain is functioning correctly and the qubit chip is responding as expected.\\n*   Since the resonator frequencies have been successfully identified, **we can proceed to the next stage of calibration**, which typically involves setting the readout tone frequencies to these specific values and performing qubit spectroscopy or Rabi oscillations to calibrate the qubit control pulses.\"\n    },\n    \"finish_reason\": \"stop\"\n  }],\n  \"usage\": {\n    \"prompt_tokens\": 408,\n    \"completion_tokens\": 335,\n    \"total_tokens\": 743\n  }\n}\n"
            },
            {
              "name": "Rabi Failure Case",
              "input": {
                "text": "I ran a time-domain Rabi experiment on my qubit. This plot shows the qubit population as a function of drive pulse duration. Can you tell me what's going on and whether I can extract a reliable pi-pulse time from it?",
                "images": [
                  "https://assets.ngc.nvidia.com/products/api-catalog/ising-calibration-1-35b-a3b/rabi_damped.png"
                ]
              },
              "output": {
                "text": "The oscillation is distorted and unreliable, so a pi-pulse time cannot be extracted confidently from this run."
              },
              "requestJson": "{\n  \"model\": \"nvidia/ising-calibration-1.5-31b\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"https://assets.ngc.nvidia.com/products/api-catalog/ising-calibration-1-35b-a3b/rabi_damped.png\"\n          }\n        },\n        {\n          \"type\": \"text\",\n          \"text\": \"I ran a time-domain Rabi experiment on my qubit. This plot shows the qubit population as a function of drive pulse duration. Can you tell me what's going on with this oscillation and whether I can extract a reliable pi-pulse time from it?\"\n        }\n      ]\n    }\n  ],\n  \"max_tokens\": 32768,\n  \"temperature\": 0.2,\n  \"top_p\": 1.0,\n  \"stream\": true\n}\n",
              "responseJson": "{\n  \"id\": \"chatcmpl-86e8ed5e253d4cb1\",\n  \"object\": \"chat.completion\",\n  \"created\": 1775613995,\n  \"model\": \"nvidia/ising-calibration-1.5-31b\",\n  \"choices\": [{\n    \"index\": 0,\n    \"message\": {\n      \"role\": \"assistant\",\n      \"content\": \"Looking at your “Time Rabi” plot, here’s what’s happening — and why you can’t reliably extract a π-pulse time from this data.\\n\\n---\\n\\n### What You’re Seeing: A Damped, Non-Sinusoidal Oscillation\\n\\nThe blue dots represent the measured qubit population ⟨Z⟩ as a function of drive pulse duration (in microseconds). The red line is a fit — likely an attempt to model Rabi oscillations with a decaying sinusoid. But visually, the data doesn’t look like clean Rabi oscillations at all.\\n\\nInstead, you see:\\n\\n- **A sharp initial drop** in ⟨Z⟩ near t=0, followed by rapid recovery.\\n- **Irregular, non-sinusoidal oscillations** after ~0.5 µs — the peaks and troughs are not symmetric or periodic.\\n- **Increasing scatter/noise** over time, especially beyond 1.5 µs.\\n- The fitted curve (red) tries to impose a smooth sine wave on chaotic data — it’s clearly a poor match for the underlying physics.\\n\\nThis behavior is *not* characteristic of coherent Rabi flopping between |0⟩ and |1⟩ states under resonant driving.\\n\\n---\\n\\n### Why This Happens: Likely Causes\\n\\n1. **Drive Frequency Detuning or Distortion**  \\n   If the drive frequency isn’t exactly on resonance with the qubit transition, or if the pulse shape is distorted (e.g., due to bandwidth limits or impedance mismatch), the Rabi oscillation will be damped, skewed, or even disappear entirely.\\n\\n2. **Qubit Relaxation/Dephasing During Drive**  \\n   While T₁ and T₂ times usually cause exponential decay of oscillation amplitude, they don’t typically distort the *shape* of the oscillation unless the drive is strong enough to induce heating or leakage to higher levels.\\n\\n3. **Measurement Artifacts or Calibration Errors**  \\n   The steep initial drop suggests something may be wrong with how the measurement is initialized or read out — perhaps the qubit isn’t starting in |0⟩, or there’s crosstalk, or the readout fidelity is very low at short times.\\n\\n4. **Strong Drive Regime or Higher-Level Transitions**  \\n   If the drive amplitude is too high, you might be driving transitions beyond |1⟩ (e.g., to |2⟩ in a transmon), which breaks the two-level approximation and leads to complex, non-sinusoidal dynamics.\\n\\n---\\n\\n### Can You Extract a π-Pulse Time?\\n\\n**No — not reliably.**\\n\\nA π-pulse corresponds to the first half-period of a clean Rabi oscillation — i.e., the time it takes to flip the qubit from |0⟩ to |1⟩. In a proper Rabi experiment, you’d expect to see:\\n\\n> ⟨Z⟩ = cos(Ω_Rabi * t) * exp(-t/T₂*) + offset\\n\\nBut here, the oscillation is too distorted to define a meaningful “half-period.” Even if you tried to fit the first minimum, it occurs around t ≈ 0.3 µs — but that point is heavily influenced by the initial transient and noise, and doesn’t correspond to a coherent rotation.\\n\\nMoreover, the subsequent oscillations don’t repeat cleanly — so you can’t average over multiple cycles to improve precision.\\n\\n---\\n\\n### What Should You Do Next?\\n\\n1. **Re-calibrate your drive frequency** — sweep the drive frequency while fixing pulse duration to find the true resonance.\\n2. **Reduce drive power** — try weaker pulses to stay in the linear (two-level) regime.\\n3. **Check pulse shaping and hardware** — ensure AWG outputs are clean, no overshoot or ringing, and cables are properly terminated.\\n4. **Verify initialization and readout** — run a simple ground-state preparation and measurement (GSPAM) sequence to confirm your qubit starts in |0⟩ and readout is reliable.\\n5. **Consider doing a Ramsey or spin echo** — if coherence is poor, Rabi won’t work well anyway; fix dephasing first.\\n\\n---\\n\\n### Bottom Line\\n\\nYour data does not show valid Rabi oscillations. The oscillation is too noisy, non-sinusoidal, and inconsistent with coherent qubit control. Therefore, **you cannot extract a reliable π-pulse time from this plot**. Go back to basics: calibrate frequency, reduce power, verify setup, then re-run the Rabi experiment.\\n\\nLet me know if you want help interpreting a corrected version of this plot!\"\n    },\n    \"finish_reason\": \"stop\"\n  }],\n  \"usage\": {\n    \"prompt_tokens\": 369,\n    \"completion_tokens\": 954,\n    \"total_tokens\": 1323\n  }\n}\n"
            },
            {
              "name": "2D Qubit Spectroscopy",
              "input": {
                "text": "This is a 2D qubit spectroscopy sweep. Where is the qubit resonance feature in this plot, at what frequency, and is the signal clear enough to use for calibration?",
                "images": [
                  "https://assets.ngc.nvidia.com/products/api-catalog/ising-calibration-1-35b-a3b/qubit_spectroscopy_2d.png"
                ]
              },
              "output": {
                "text": "The resonance feature is centered around 4500 MHz and the signal is clear enough for calibration."
              },
              "requestJson": "{\n  \"model\": \"nvidia/ising-calibration-1.5-31b\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"https://assets.ngc.nvidia.com/products/api-catalog/ising-calibration-1-35b-a3b/qubit_spectroscopy_2d.png\"\n          }\n        },\n        {\n          \"type\": \"text\",\n          \"text\": \"This is a 2D qubit spectroscopy sweep — I varied the drive frequency and amplitude to locate my qubit. Where is the qubit resonance feature in this plot, and at what frequency? Is the signal clear enough to use for calibration?\"\n        }\n      ]\n    }\n  ],\n  \"max_tokens\": 32768,\n  \"temperature\": 0.2,\n  \"top_p\": 1.0,\n  \"stream\": true\n}\n",
              "responseJson": "{\n  \"id\": \"chatcmpl-9f0dd6a776a1c3af\",\n  \"object\": \"chat.completion\",\n  \"created\": 1775614002,\n  \"model\": \"nvidia/ising-calibration-1.5-31b\",\n  \"choices\": [{\n    \"index\": 0,\n    \"message\": {\n      \"role\": \"assistant\",\n      \"content\": \"Looking at the provided 2D qubit spectroscopy magnitude sweep plot:\\n\\n- The x-axis represents **Frequency [MHz]**, ranging from ~4390 to 4660 MHz.\\n- The y-axis represents **Qubit driving amplitude [a.u.]**, ranging from ~0.005 to 0.018 a.u.\\n- The color scale indicates **Magnitude**, with darker purple (lower magnitude) indicating stronger resonance features (since in spectroscopy, dips or minima often correspond to resonant absorption).\\n\\n### Observation:\\nThere is a clear, vertical dark band centered around **~4500 MHz** (specifically, between 4490–4510 MHz), which persists across nearly the entire range of driving amplitudes. This vertical feature suggests that the qubit’s resonant frequency is largely independent of drive amplitude — which is expected for a two-level system under weak driving, where the resonance frequency doesn’t shift significantly with power (unlike anharmonicity-induced shifts that appear at higher powers).\\n\\nThe depth of the dip (dark purple) reaches down to ~8 on the magnitude scale, while background values are ~9–10.5, indicating a signal-to-noise ratio of roughly 1–1.5 dB — acceptable for initial calibration.\\n\\n### Conclusion:\\n✅ **Yes, the signal is clear enough to use for calibration.**\\n\\nThe qubit resonance is located at approximately **4500 MHz** (more precisely, ~4500 ± 10 MHz). The vertical alignment confirms it’s a true resonance feature and not an artifact. You can proceed to set your spectroscopy tone at this frequency for further characterization (e.g., Rabi oscillations, T1, etc.).\\n\\n---\\n\\n*Note: In some setups, you might expect a slight curve or shift at higher amplitudes due to AC Stark shift or anharmonicity — but here the feature is remarkably flat, suggesting either a well-isolated two-level system or modest drive powers used.*\"\n    },\n    \"finish_reason\": \"stop\"\n  }],\n  \"usage\": {\n    \"prompt_tokens\": 366,\n    \"completion_tokens\": 426,\n    \"total_tokens\": 792\n  }\n}\n"
            }
          ],
          "templates": [
            {
              "title": "Default",
              "requestEjs": {
                "python": "<% let pyStream = request.stream.toString()[0].toUpperCase() + request.stream.toString().slice(1) %>\nimport requests, base64\n\ninvoke_url = \"https://integrate.api.nvidia.com/v1/chat/completions\"\nstream = <%- pyStream %>\n<%\n  const messages = JSON.stringify(request.messages)\n  const firstContent = typeof request.messages?.[0]?.content === \"string\" ? request.messages[0].content : \"\";\n  const hasImage = /<img[^>]*\\/?>/i.test(firstContent);\n  const imageCount = (firstContent.match(/<img[^>]*\\/?>/gi) || []).length;\n  let rendered_messages;\n\n  if (hasImage) {\n    const tagRegex = /<img\\b[^>]*\\/?>/gi;\n    const contentParts = [];\n    let imgIdx = 0;\n    let lastIdx = 0;\n    let tagMatch;\n    while ((tagMatch = tagRegex.exec(firstContent)) !== null) {\n      const leadingText = firstContent.slice(lastIdx, tagMatch.index);\n      if (leadingText.trim()) {\n        contentParts.push({ type: \"text\", text: leadingText });\n      }\n      contentParts.push({\n        type: \"image_url\",\n        image_url: { url: `__IMAGE_${imgIdx}__` }\n      });\n      imgIdx += 1;\n      lastIdx = tagRegex.lastIndex;\n    }\n    const trailingText = firstContent.slice(lastIdx);\n    if (trailingText.trim()) {\n      contentParts.push({ type: \"text\", text: trailingText });\n    }\n    let renderedContent = JSON.stringify(contentParts, null, 8);\n    for (let i = 0; i < imgIdx; i++) {\n      renderedContent = renderedContent.replace(\n        `\"__IMAGE_${i}__\"`,\n        `f\"data:image/png;base64,{image_b64s[${i}]}\"`,\n      );\n    }\n\n    rendered_messages = `[\n      {\n        \"role\": \"user\",\n        \"content\": ${renderedContent}\n      }\n    ]`;\n  } else {\n    rendered_messages = messages\n  }\n%>\ndef read_b64(path):\n  with open(path, \"rb\") as f:\n    return base64.b64encode(f.read()).decode()\n<% if (imageCount > 0) { %>image_b64s = [read_b64(f\"image_{i}.png\") for i in range(1, <%- imageCount + 1 %>)]\n<% } %>\nheaders = {\n  \"Authorization\": \"Bearer $NVIDIA_API_KEY\",\n  \"Accept\": \"text/event-stream\" if stream else \"application/json\"\n}\n\npayload = {\n  \"model\": \"<%- request.model %>\",\n  \"messages\": <%- rendered_messages %>,\n  \"max_tokens\": <%- request.max_tokens %>,\n  \"temperature\": <%- request.temperature.toFixed(2) %>,\n  \"top_p\": <%- request.top_p.toFixed(2) %>,\n  \"stream\": stream,\n  <%- request.chat_template_kwargs ? \"\\\"chat_template_kwargs\\\": \" + JSON.stringify(request.chat_template_kwargs).replaceAll(\"true\", \"True\").replaceAll(\"false\", \"False\") + \",\" : \"\" %>\n}\nresponse = requests.post(invoke_url, headers=headers, json=payload, stream=stream)\nif stream:\n    for line in response.iter_lines():\n        if line:\n            print(line.decode(\"utf-8\"))\nelse:\n    print(response.json())\n",
                "langChain": "<%\n  const lcMessages = JSON.stringify(request.messages)\n  const lcFirstContent = typeof request.messages?.[0]?.content === \"string\" ? request.messages[0].content : \"\";\n  const lcHasImage = /<img[^>]*\\/?>/i.test(lcFirstContent);\n  const lcImageCount = (lcFirstContent.match(/<img[^>]*\\/?>/gi) || []).length;\n  const lcText = lcFirstContent\n    .replace(/<img\\b[^>]*\\/?>/gi, ' ')\n    .replace(/\\s+/g, ' ')\n    .trim();\n%>\nfrom langchain_nvidia_ai_endpoints import ChatNVIDIA\n<% if (lcHasImage) { %>from langchain_core.messages import HumanMessage\nimport base64\n<% } %>\n\nclient = ChatNVIDIA(\n  model=\"<%- request.model %>\",\n  api_key=\"$NVIDIA_API_KEY\",\n  temperature=<%- request.temperature %>,\n  top_p=<%- request.top_p %>,\n  max_completion_tokens=<%- request.max_tokens %>,\n)\n<% if (lcHasImage) { %>\ndef read_b64(path):\n  with open(path, \"rb\") as f:\n    return base64.b64encode(f.read()).decode()\nimage_b64s = [read_b64(f\"image_{i}.png\") for i in range(1, <%- lcImageCount + 1 %>)]\ncontent = []\n<% if (lcText) { %>content.append({\"type\": \"text\", \"text\": <%- JSON.stringify(lcText) %>})\n<% } %>for image_b64 in image_b64s:\n  content.append({\"type\": \"image_url\", \"image_url\": {\"url\": f\"data:image/png;base64,{image_b64}\"}})\nlc_messages = [HumanMessage(content=content)]\n<% } else { %>\nlc_messages = <%- lcMessages %>\n<% } %>\n<% if (request.stream) { %>\nfor chunk in client.stream(lc_messages):\n  print(chunk.content, end=\"\")\n<% } else { %>\nresponse = client.invoke(lc_messages)\nprint(response.content)\n<% } %>\n",
                "node.js": "import axios from 'axios';\nimport { readFile } from 'node:fs/promises';\n\nconst invokeUrl = \"https://integrate.api.nvidia.com/v1/chat/completions\";\nconst stream = <%- request.stream %>;\n<%\n  const messages = JSON.stringify(request.messages)\n  const firstContent = typeof request.messages?.[0]?.content === \"string\" ? request.messages[0].content : \"\";\n  const hasImage = /<img[^>]*\\/?>/i.test(firstContent);\n  const imageCount = (firstContent.match(/<img[^>]*\\/?>/gi) || []).length;\n  let rendered_messages;\n\n  if (hasImage) {\n    const tagRegex = /<img\\b[^>]*\\/?>/gi;\n    const contentParts = [];\n    let imgIdx = 0;\n    let lastIdx = 0;\n    let tagMatch;\n    while ((tagMatch = tagRegex.exec(firstContent)) !== null) {\n      const leadingText = firstContent.slice(lastIdx, tagMatch.index);\n      if (leadingText.trim()) {\n        contentParts.push({ type: \"text\", text: leadingText });\n      }\n      contentParts.push({\n        type: \"image_url\",\n        image_url: { url: `__IMAGE_${imgIdx}__` }\n      });\n      imgIdx += 1;\n      lastIdx = tagRegex.lastIndex;\n    }\n    const trailingText = firstContent.slice(lastIdx);\n    if (trailingText.trim()) {\n      contentParts.push({ type: \"text\", text: trailingText });\n    }\n    let renderedContent = JSON.stringify(contentParts, null, 8);\n    for (let i = 0; i < imgIdx; i++) {\n      renderedContent = renderedContent.replace(\n        `\"__IMAGE_${i}__\"`,\n        `\\`data:image/png;base64,\\${image_${i + 1}_b64}\\``,\n      );\n    }\n\n    rendered_messages = `[\n      {\n        \"role\": \"user\",\n        \"content\": ${renderedContent}\n      }\n    ]`;\n  } else {\n    rendered_messages = messages\n  }\n%>\nconst headers = {\n  \"Authorization\": \"Bearer $NVIDIA_API_KEY\",\n  \"Accept\": stream ? \"text/event-stream\" : \"application/json\"\n};\n<% if (hasImage) { %>\nPromise.all([<% for (let i = 1; i <= imageCount; i++) { %>readFile(\"image_<%- i %>.png\"), <% } %>])\n  .then((imageBuffers) => {\n    <% for (let i = 1; i <= imageCount; i++) { %>const image_<%- i %>_b64 = Buffer.from(imageBuffers[<%- i - 1 %>]).toString('base64');\n    <% } %>\n\n    const payload = {\n      \"model\": `<%- request.model %>`,\n      \"messages\": <%- rendered_messages %>,\n      \"max_tokens\": <%- request.max_tokens %>,\n      \"temperature\": <%- request.temperature.toFixed(2) %>,\n      \"top_p\": <%- request.top_p.toFixed(2) %>,\n      \"stream\": stream,\n      <%- request.chat_template_kwargs ? \"\\\"chat_template_kwargs\\\": \" + JSON.stringify(request.chat_template_kwargs) + \",\" : \"\" %>\n    };\n\n    return axios.post(invokeUrl, payload, { headers: headers, responseType: stream ? 'stream' : 'json' });\n  })\n<% } else { %>\nconst payload = {\n  \"model\": \"<%- request.model %>\",\n  \"messages\": <%- rendered_messages %>,\n  \"max_tokens\": <%- request.max_tokens %>,\n  \"temperature\": <%- request.temperature.toFixed(2) %>,\n  \"top_p\": <%- request.top_p.toFixed(2) %>,\n  \"stream\": stream,\n  <%- request.chat_template_kwargs ? \"\\\"chat_template_kwargs\\\": \" + JSON.stringify(request.chat_template_kwargs) + \",\" : \"\" %>\n};\n\nPromise.resolve(\n  axios.post(invokeUrl, payload, {\n    headers: headers,\n    responseType: stream ? 'stream' : 'json'\n  })\n)\n<% } %>\n  .then(response => {\n    if (stream) {\n      response.data.on('data', (chunk) => {\n        console.log(chunk.toString());\n      });\n    } else {\n      console.log(JSON.stringify(response.data));\n    }\n  })\n  .catch(error => {\n    if (error.response) {\n      console.error(`HTTP ${error.response.status}`);\n      if (error.response.data?.on) {\n        error.response.data.on('data', (chunk) => console.error(chunk.toString()));\n      } else {\n        console.error(error.response.data);\n      }\n    } else {\n      console.error(error);\n    }\n  });\n",
                "curl": "stream=<%- request.stream %>\nif [ \"$stream\" = true ]; then\n    accept_header='Accept: text/event-stream'\nelse\n    accept_header='Accept: application/json'\nfi\n<%\n  const messages = JSON.stringify(request.messages)\n  const firstContent = typeof request.messages?.[0]?.content === \"string\" ? request.messages[0].content : \"\";\n  const hasImage = /<img[^>]*\\/?>/i.test(firstContent);\n  const imageCount = (firstContent.match(/<img[^>]*\\/?>/gi) || []).length;\n  let rendered_messages;\n\n  if (hasImage) {\n    const tagRegex = /<img\\b[^>]*\\/?>/gi;\n    const contentParts = [];\n    let imgIdx = 0;\n    let lastIdx = 0;\n    let tagMatch;\n    while ((tagMatch = tagRegex.exec(firstContent)) !== null) {\n      const leadingText = firstContent.slice(lastIdx, tagMatch.index);\n      if (leadingText.trim()) {\n        contentParts.push({ type: \"text\", text: leadingText });\n      }\n      contentParts.push({\n        type: \"image_url\",\n        image_url: { url: `data:image/png;base64,\\${image_${imgIdx + 1}_b64}` }\n      });\n      imgIdx += 1;\n      lastIdx = tagRegex.lastIndex;\n    }\n    const trailingText = firstContent.slice(lastIdx);\n    if (trailingText.trim()) {\n      contentParts.push({ type: \"text\", text: trailingText });\n    }\n    rendered_messages = JSON.stringify([{ role: \"user\", content: contentParts }], null, 4);\n  } else {\n    rendered_messages = messages\n  }\n%>\n<% for (let i = 1; i <= imageCount; i++) { %>\nimage_<%- i %>_b64=$( base64 < image_<%- i %>.png | tr -d '\\n' )\n<% } %>\n\ncat > payload.json <<JSON\n{\n  \"model\": \"<%- request.model %>\",\n  \"messages\": <%- rendered_messages %>,\n  \"max_tokens\": <%- request.max_tokens %>,\n  \"temperature\": <%- request.temperature.toFixed(2) %>,\n  \"top_p\": <%- request.top_p.toFixed(2) %>,\n  \"stream\": <%- request.stream %><%- request.chat_template_kwargs ? \",\\n  \\\"chat_template_kwargs\\\": \" + JSON.stringify(request.chat_template_kwargs) : \"\" %>\n}\nJSON\n\ncurl https://integrate.api.nvidia.com/v1/chat/completions \\\n-H \"Authorization: Bearer $NVIDIA_API_KEY\" \\\n-H \"Content-Type: application/json\" \\\n-H \"$accept_header\" \\\n-d @payload.json\n"
              },
              "response": "{\n  \"choices\": [{\n    \"index\": 0,\n    \"model\": \"nvidia/ising-calibration-1.5-31b\",\n    \"message\": {\n      \"role\": \"assistant\",\n      \"content\": \"...\",\n    },\n    \"finish_reason\": \"stop\"\n  }],\n  \"usage\": {\n    \"prompt_tokens\": 9,\n    \"completion_tokens\": 12,\n    \"total_tokens\": 21\n  }\n}\n"
            }
          ]
        }
      }
    }
  },
  "security": [
    {
      "Token": []
    }
  ],
  "components": {
    "securitySchemes": {
      "Token": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "ChatCompletionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "object": {
            "type": "string",
            "enum": [
              "chat.completion"
            ],
            "const": "chat.completion",
            "title": "Object",
            "default": "chat.completion"
          },
          "created": {
            "type": "integer",
            "title": "Created"
          },
          "model": {
            "type": "string",
            "title": "Model"
          },
          "choices": {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionResponseChoice"
            },
            "type": "array",
            "title": "Choices"
          },
          "usage": {
            "$ref": "#/components/schemas/UsageInfo"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "model",
          "choices",
          "usage"
        ],
        "title": "ChatCompletionResponse"
      },
      "ChatCompletionResponseChoice": {
        "properties": {
          "index": {
            "type": "integer",
            "title": "Index"
          },
          "message": {
            "$ref": "#/components/schemas/ChatMessage"
          },
          "finish_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "stop",
                  "length"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Reason"
          },
          "stop_reason": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "index",
          "message"
        ],
        "title": "ChatCompletionResponseChoice"
      },
      "ChatCompletionResponseStreamChoice": {
        "properties": {
          "index": {
            "type": "integer",
            "title": "Index"
          },
          "delta": {
            "$ref": "#/components/schemas/DeltaMessage"
          },
          "finish_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "stop",
                  "length"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Reason"
          },
          "stop_reason": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "index",
          "delta"
        ],
        "title": "ChatCompletionResponseStreamChoice"
      },
      "ChatCompletionStreamResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "object": {
            "type": "string",
            "enum": [
              "chat.completion.chunk"
            ],
            "const": "chat.completion.chunk",
            "title": "Object",
            "default": "chat.completion.chunk"
          },
          "created": {
            "type": "integer",
            "title": "Created"
          },
          "model": {
            "type": "string",
            "title": "Model"
          },
          "choices": {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionResponseStreamChoice"
            },
            "type": "array",
            "title": "Choices"
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UsageInfo"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "model",
          "choices"
        ],
        "title": "ChatCompletionStreamResponse"
      },
      "ChatMessage": {
        "properties": {
          "role": {
            "type": "string",
            "title": "Role"
          },
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "role"
        ],
        "title": "ChatMessage"
      },
      "DeltaMessage": {
        "properties": {
          "role": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Role"
          },
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "DeltaMessage"
      },
      "ErrorResponse": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "error"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Type"
          },
          "param": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Param"
          },
          "code": {
            "type": "integer",
            "title": "Code"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "message",
          "type",
          "code"
        ],
        "title": "ErrorResponse"
      },
      "ImageURL": {
        "properties": {
          "url": {
            "type": "string",
            "title": "Url"
          }
        },
        "type": "object",
        "required": [
          "url"
        ],
        "title": "ImageURL"
      },
      "NIMLLMChatCompletionMessage": {
        "properties": {
          "role": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Role"
              }
            ],
            "description": "The role of the message's author."
          },
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "items": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/NIMVLMChatCompletionContentPartImage"
                    },
                    {
                      "$ref": "#/components/schemas/NIMVLMChatCompletionContentPartText"
                    }
                  ]
                },
                "type": "array"
              }
            ],
            "title": "Content",
            "description": "The contents of the message.\n        <br>To pass images (only with role=`user`):\n        <br>    - When content is a string, image can be passed together with the text with `img` HTML tags that wraps \n        an image URL (`<img src=\"{url}\" />`), \n        base64 encoded image data (`<img src=\"data:image/{format};base64,{base64encodedimage}\" />`), \n        or an NVCF asset ID (`<img src=\"data:image/{format};asset_id,{asset_id}\" />`) \n        when the container is hosted in NVCF and the payload exceeds 200KB.\n        <br>    - When content is a list of objects, images can be passed as objects with type=`image_url`.\n        <br>    - In both cases, images can be PNG, JPG or JPEG.\n        <br>For `system` and `assistant` roles, the object list format is not supported.\n        "
          }
        },
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "title": "NIMLLMChatCompletionMessage"
      },
      "NIMLLMChatCompletionRequest": {
        "properties": {
          "messages": {
            "items": {
              "$ref": "#/components/schemas/NIMLLMChatCompletionMessage"
            },
            "type": "array",
            "minItems": 1,
            "title": "Messages",
            "description": "A list of messages comprising the conversation so far."
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "The model to use.",
            "default": "nvidia/ising-calibration-1.5-31b"
          },
          "max_tokens": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 32768,
                "minimum": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Tokens",
            "description": "The maximum number of tokens that can be generated.",
            "default": 32768
          },
          "seed": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 9223372036854776000,
                "minimum": -9223372036854776000
              },
              {
                "type": "null"
              }
            ],
            "title": "Seed",
            "description": "Changing the seed will produce a different response with similar characteristics. Fixing the seed will reproduce the same results if all other parameters are also kept constant."
          },
          "stream": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stream",
            "description": "If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]`",
            "default": false
          },
          "temperature": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1,
                "minimum": 0
              },
              {
                "type": "null"
              }
            ],
            "title": "Temperature",
            "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
            "default": 1
          },
          "top_p": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1,
                "exclusiveMinimum": 0
              },
              {
                "type": "null"
              }
            ],
            "title": "Top P",
            "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.",
            "default": 0.95
          },
          "top_k": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Top K",
            "description": "The number of highest probability vocabulary tokens to keep for top-k sampling.",
            "default": 64
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "messages",
          "model"
        ],
        "title": "NIMLLMChatCompletionRequest"
      },
      "NIMVLMChatCompletionContentPartImage": {
        "properties": {
          "image_url": {
            "$ref": "#/components/schemas/ImageURL"
          },
          "type": {
            "type": "string",
            "enum": [
              "image_url"
            ],
            "const": "image_url",
            "title": "Type"
          }
        },
        "type": "object",
        "required": [
          "image_url",
          "type"
        ],
        "title": "NIMVLMChatCompletionContentPartImage"
      },
      "NIMVLMChatCompletionContentPartText": {
        "properties": {
          "text": {
            "type": "string",
            "title": "Text"
          },
          "type": {
            "type": "string",
            "enum": [
              "text"
            ],
            "const": "text",
            "title": "Type"
          }
        },
        "type": "object",
        "required": [
          "text",
          "type"
        ],
        "title": "NIMVLMChatCompletionContentPartText"
      },
      "Role": {
        "type": "string",
        "enum": [
          "assistant",
          "user"
        ],
        "title": "Role"
      },
      "UsageInfo": {
        "properties": {
          "prompt_tokens": {
            "type": "integer",
            "title": "Prompt Tokens",
            "default": 0
          },
          "total_tokens": {
            "type": "integer",
            "title": "Total Tokens",
            "default": 0
          },
          "completion_tokens": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completion Tokens",
            "default": 0
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "UsageInfo"
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```