Skip to navigation

API Reference

View as Markdown

Use this reference to look up the HTTP and gRPC inference contracts. For a complete deployment walkthrough, start with the Quickstart.

HTTP Endpoints

The release HTTP server exposes the following routes:

CategoryMethod and RoutePurpose
InferencePOST /v1/inferNative Harmonizer request and response schema.
HealthGET /v1/health/liveProcess or server liveness.
HealthGET /v1/health/readyService readiness for inference.
ManagementGET /v1/metricsPrometheus metrics in text exposition format.
ManagementGET /v1/licensePackaged NIM license information and content.
ManagementGET /v1/metadataVersion, license, selected profile, and model metadata.
ManagementGET /v1/versionNIM release and API versions.
ManagementGET /v1/manifestActive model manifest and repository override.
ManagementGET /v1/modelsServed model in the standard NIM model-list shape.

The NIM also exposes a binary gRPC API on port 50051 that mirrors the /v1/infer payload as harmonizer.v1.Harmonizer/Process.

API Examples

Use the examples in this section to get started with the API.

The examples use localhost because Docker publishes the port on the client host. For a remote NIM, replace it with the server host name or IP address. From inside Kubernetes, use the Service DNS name. 0.0.0.0 is a server listen address and should not be used as a client destination.

Check Health

Use the following command to check server readiness.

cURL Request

curl -X 'GET' 'http://localhost:8000/v1/health/ready'

Response

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

For the HTTP entrypoint, model loading and startup warmup complete before the server begins accepting connections. During that phase a client normally sees a connection failure or a pending deployment startup probe, not an HTTP 503. After the server is reachable, 200 with "status": "ready" means the backend is ready. A running HTTP server can return 503 if its internal backend readiness state later becomes false.

For the gRPC entrypoint, the model also loads and warms before the gRPC server starts. The standard grpc.health.v1.Health/Check service changes to SERVING after server startup and to NOT_SERVING during shutdown or during the short transition between detecting an unrecoverable CUDA error and terminating the inference process. Its companion HTTP live and ready routes query that gRPC health service. Deployment probes should use /v1/health/ready.

Process Images

Use the process endpoint to enhance one or more images. The images list is ordered: with context_length=4 the list is treated as a frame sequence and the temporal lane builds autoregressive context from previously generated outputs. With context_length=0 each image is processed independently. Each returned image or tensor has the corresponding input’s original dimensions. The runtime stretches the input to 1024x576 for inference and stretches the result back to the original dimensions. Both processing modes are available through either inference transport. A container activates one inference transport at startup, so the HTTP and gRPC tabs below are alternatives rather than simultaneous inference endpoints. See the Quickstart for the corresponding launch commands.

Use POST /v1/infer for the native Harmonizer schema. HTTP image payloads are base64-encoded PNG or JPEG bytes.

This example uses an input frame from the NVIDIA Harmonizer model-publication repository. The API accepts encoded image data rather than an image URL, so the first command downloads the frame as input.png. The remaining commands insert its complete base64 payload into the request.

cURL Request

curl -L \
https://raw.githubusercontent.com/NVIDIA/harmonizer/d1234ff7afb00b6084967dc31b18b526c9b9e7e0/examples/0.png \
-o input.png
IMAGE_B64="$(base64 < input.png | tr -d '\n')"
curl -X 'POST' \
'http://localhost:8000/v1/infer' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data-binary @- <<EOF
{
"request_id": "demo-0001",
"images": [
{
"id": "frame-000000",
"data": "${IMAGE_B64}"
}
],
"parameters": {
"output_format": "png",
"context_length": 0,
"return_policy": "all"
}
}
EOF

Response

The dimensions below are for a 1024x576 input image.

{
"request_id": "demo-0001",
"outputs": [
{
"id": "frame-000000",
"image": {
"data": "<base64 png>",
"mime_type": "image/png",
"width": 1024,
"height": 576
},
"tensor": null
}
]
}

Transport Parameter Values

HTTP represents parameter choices as strings. gRPC represents the same choices as protobuf enums.

ParameterHTTP ValuegRPC Value
output_formatpngOUTPUT_FORMAT_PNG
output_formatjpegOUTPUT_FORMAT_JPEG
output_formatraw_tensorOUTPUT_FORMAT_RAW_TENSOR
return_policyallRETURN_POLICY_ALL
return_policyexclude_contextRETURN_POLICY_EXCLUDE_CONTEXT
return_policylastRETURN_POLICY_LAST

Request Fields

The following table describes the request fields:

FieldDescription
request_idOptional client-supplied request identifier echoed back in the response.
imagesOrdered list of input images. Each image carries exactly one of data (base64 PNG/JPEG over HTTP, bytes over gRPC) or tensor (raw uint8 RGB tensor). Encoded formats are detected from the payload.
parametersOptional. If omitted, the NIM uses output_format=png, context_length=0, and return_policy=all.
parameters.output_formatOptional. png (default), jpeg, or raw_tensor.
parameters.context_lengthOptional. 0 (default) for the independent image lane or 4 for the rolling temporal lane. This NIM release supports only these two values.
parameters.return_policyOptional. all (default), exclude_context, or last.

Raw Tensor Response

For HTTP responses, both image and tensor keys are serialized and exactly one is non-null. gRPC represents the alternatives as a protobuf oneof. With output_format=raw_tensor, HTTP base64-encodes tensor.data and gRPC returns it as bytes. The decoded payload contains tightly packed RGB uint8 values in the [0, 255] range. Output layout is always HWC and output shape is [height, width, 3].

The following HTTP response is for a 1024x576 input:

{
"request_id": "demo-0001",
"outputs": [
{
"id": "frame-000000",
"image": null,
"tensor": {
"data": "<base64 uint8 RGB bytes>",
"shape": [576, 1024, 3],
"layout": "HWC"
}
}
]
}

Response Fields

The following table describes the response fields:

FieldDescription
request_idClient-supplied request identifier, when provided.
outputsProcessed outputs in input order, subject to return_policy. Each output carries its optional input id and exactly one non-null image or tensor payload. Its dimensions match the corresponding input’s original dimensions.

Model and NIM Information

Use the standard NIM management endpoints rather than inference responses for service and model information. /v1/version reports the release and API versions; /v1/metadata combines version, license, model, and selected-profile information; /v1/models identifies the served model; and /v1/manifest returns the active model manifest. /v1/license returns the packaged license, and /v1/metrics returns Prometheus text rather than JSON.

Error Handling

The HTTP API returns standard status codes to indicate success or failure:

  • 200 OK: Request successful
  • 400 Bad Request: nimlib request-body validation or invalid input parameters (for example an unsupported context_length or an invalid return_policy for the request shape)
  • 503 Service Unavailable: A running backend becomes unavailable
  • 500 Internal Server Error: Server-side error

Every HTTP error uses the {"error": ...} envelope shown below. The nested error object always contains the required message, type, and code fields; the OpenAPI schema defines their types.

A missing model artifact normally fails model loading before the HTTP or gRPC server starts, so clients see startup failure rather than an inference response. The current nimlib configuration includes field-specific validation details. For example, setting both image payload fields returns:

{
"error": {
"message": "images -> 0: Value error, exactly one of data or tensor must be set",
"type": "BadRequestError",
"code": 400
}
}

The gRPC API uses standard gRPC status codes:

  • OK (code 0): The RPC completed successfully
  • INVALID_ARGUMENT: Invalid input parameters or malformed payload
  • UNAVAILABLE: Model backend is not loaded
  • UNKNOWN: Unhandled server-side error

OpenAPI Specification

The HTTP OpenAPI specification is generated from the release nimlib interface and packaged at /opt/nim/api_spec.yaml inside the container. The interactive endpoint reference is available in the API Reference tab.