{"library":"tritonclient","code":"import numpy as np\nimport tritonclient.http as tritonhttp\nimport os\n\nTRITON_SERVER_URL = os.environ.get('TRITON_SERVER_URL', 'localhost:8000')\nMODEL_NAME = 'simple_model'\nMODEL_VERSION = '1'\nINPUT_NAME = 'input_0'\nOUTPUT_NAME = 'output_0'\n\ndef main():\n    try:\n        # Create a Triton HTTP client\n        client = tritonhttp.InferenceServerClient(url=TRITON_SERVER_URL)\n\n        # Check server readiness\n        if not client.is_server_ready():\n            print(f\"Triton server at {TRITON_SERVER_URL} is not ready.\")\n            return\n        print(f\"Triton server at {TRITON_SERVER_URL} is ready.\")\n\n        # Prepare input data (e.g., a simple numpy array)\n        input_data = np.random.rand(1, 16).astype(np.float32)\n        \n        # Create InferInput object\n        infer_input = tritonhttp.InferInput(INPUT_NAME, input_data.shape, 'FP32')\n        infer_input.set_data_from_numpy(input_data, binary_data=True)\n\n        # Create InferRequestedOutput object\n        infer_output = tritonhttp.InferRequestedOutput(OUTPUT_NAME, binary_data=True)\n\n        # Send inference request\n        response = client.infer(\n            model_name=MODEL_NAME,\n            inputs=[infer_input],\n            outputs=[infer_output],\n            model_version=MODEL_VERSION\n        )\n\n        # Get output as numpy array\n        output_data = response.as_numpy(OUTPUT_NAME)\n        print(f\"Inference successful! Output shape: {output_data.shape}\")\n        print(f\"First 5 output values: {output_data.flatten()[:5]}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to initialize an HTTP client, check server readiness, prepare input tensors using NumPy, send an inference request to a hypothetical 'simple_model', and process the returned output. Remember to replace `TRITON_SERVER_URL`, `MODEL_NAME`, `MODEL_VERSION`, `INPUT_NAME`, and `OUTPUT_NAME` with your actual server and model details. For gRPC, import `tritonclient.grpc` instead and use `tritonclient.grpc.InferenceServerClient`.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}