
Cuopt Server Api Python
Call the NVIDIA cuOpt REST API from Python to submit and solve linear programming models against a running cuOpt server.
Overview
cuopt-server-api-python is an agent skill for the Build phase that provides a Python REST client for submitting linear programming jobs to a running NVIDIA cuOpt server.
Install
npx skills add https://github.com/nvidia/skills --skill cuopt-server-api-pythonWhat is this skill?
- Python requests client posting JSON LP models to a cuOpt server with health-check guard
- Example maximize objective with two variables and two linear constraints in CSR matrix form
- Honors CUOPT_SERVER_URL (default http://localhost:8000) and exits cleanly when the server is unreachable—useful in CI wi
- Documents required headers including Content-Type and CLIENT-VERSION for custom clients
- Apache-2.0 licensed NVIDIA sample oriented around cuopt/health verification before solve requests
- Sample LP uses 2 decision variables and 2 linear constraints in CSR form
- Default server URL http://localhost:8000 overridable via CUOPT_SERVER_URL
- Health probe targets /cuopt/health with a 2-second timeout
Adoption & trust: 1 installs on skills.sh; 1.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have LP coefficients and constraints in Python but no reliable HTTP client pattern to talk to NVIDIA cuOpt’s server API or to behave safely when the server is down.
Who is it for?
Indie builders or small teams already running cuOpt server who need a copy-paste Python integration for optimization microservices or batch jobs.
Skip if: Projects without a cuOpt server deployment, non-Python stacks, or teams seeking full solver theory instead of API wiring.
When should I use this skill?
You need a Python script to POST LP models to a running NVIDIA cuOpt server and want the documented JSON shape plus graceful skip when the server is offline.
What do I get? / Deliverables
You get a working Python request flow with health checks, CSR JSON payloads, and environment-based server URLs so your agent can integrate cuOpt solves into backend scripts or services.
- Runnable Python REST client for cuOpt LP submission
- Reference JSON payload for CSR constraints, bounds, and maximize objective
- CI-friendly behavior when cuOpt server is not running
Recommended Skills
Journey fit
Build backend is the canonical shelf because the skill is a Python REST client and payload contract for optimization workloads, not infra provisioning or growth analytics. Backend fits server-side Python that serializes CSR constraint matrices, bounds, and objective coefficients to the cuOpt HTTP service.
How it compares
An integration sample for NVIDIA’s hosted cuOpt HTTP API—not a general OR toolkit or MCP optimization server.
Common Questions / FAQ
Who is cuopt-server-api-python for?
Python developers integrating NVIDIA cuOpt into backends, scripts, or CI smoke tests that POST linear programming models to a cuOpt REST service.
When should I use cuopt-server-api-python?
During Build backend work when you are connecting application code to an already planned cuOpt server instance and need the CSR JSON payload and health-check pattern.
Is cuopt-server-api-python safe to install?
Consult the Security Audits panel on this Prism page for audit status and risk before running network clients against internal optimization endpoints.
SKILL.md
READMESKILL.md - Cuopt Server Api Python
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 """ REST client: LP request (maximize 40x + 30y s.t. 2x+3y<=240, 4x+2y<=200). Requires cuOpt server running. Usage: python client.py Set CUOPT_SERVER_URL (default http://localhost:8000). Exits 0 if server unreachable (e.g. in CI without server). """ import os import sys import time import requests SERVER = os.environ.get("CUOPT_SERVER_URL", "http://localhost:8000") HEADERS = {"Content-Type": "application/json", "CLIENT-VERSION": "custom"} def server_ok(): try: r = requests.get(f"{SERVER}/cuopt/health", timeout=2) return r.status_code == 200 except Exception: return False def main(): if not server_ok(): print( "Server not running, skipping. Start with: python -m cuopt_server.cuopt_service --ip 0.0.0.0 --port 8000" ) sys.exit(0) payload = { "csr_constraint_matrix": { "offsets": [0, 2, 4], "indices": [0, 1, 0, 1], "values": [2.0, 3.0, 4.0, 2.0], }, "constraint_bounds": { "upper_bounds": [240.0, 200.0], "lower_bounds": ["ninf", "ninf"], }, "objective_data": { "coefficients": [40.0, 30.0], }, "variable_bounds": { "upper_bounds": ["inf", "inf"], "lower_bounds": [0.0, 0.0], }, "maximize": True, "solver_config": { "time_limit": 60, }, } response = requests.post( f"{SERVER}/cuopt/request", json=payload, headers=HEADERS ) response.raise_for_status() req_id = response.json()["reqId"] print(f"Submitted: {req_id}") for _ in range(30): response = requests.get( f"{SERVER}/cuopt/solution/{req_id}", headers=HEADERS ) result = response.json() if "response" in result: print(f"Status: {result['response'].get('status')}") print(f"Objective: {result['response'].get('objective_value')}") print(f"Solution: {result['response'].get('primal_solution')}") return time.sleep(1) print("Timeout waiting for solution") sys.exit(1) if __name__ == "__main__": main() # LP via REST (maximize 40x + 30y) Submit an LP to the cuOpt server (CSR format) and poll for the solution. **Requires:** cuOpt server running (e.g. `python -m cuopt_server.cuopt_service --ip 0.0.0.0 --port 8000`). **Run:** `python client.py` If the server is not reachable, the script exits 0 (skip). **Env:** `CUOPT_SERVER_URL` (default `http://localhost:8000`). # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 """ REST client: MILP (same constraints as LP but variable_types: integer, continuous). Requires cuOpt server running. Exits 0 if server unreachable. """ import os import sys import time import requests SERVER = os.environ.get("CUOPT_SERVER_URL", "http://localhost:8000") HEADERS = {"Content-Type": "application/json", "CLIENT-VERSION": "custom"} def server_ok(): try: r = requests.get(f"{SERVER}/cuopt/health", timeout=2) return r.status_code == 200 except Exception: return False def main(): if not server_ok(): print( "Server not running, skipping. Start with: python -m cuopt_server.cuopt_service --ip 0.0.0.0 --port 8000" ) sys.exit(0) payload = { "csr_constraint_matrix": { "offsets": [0, 2, 4], "indices": [0, 1, 0, 1], "values": [2.0, 3.0, 4.0, 2.0], }, "constraint_bounds": { "upper_bounds": [240.0, 200.0], "lower_bounds": ["ninf", "ninf"], }, "objective_data": {"coefficients": [40.0, 30.0]}, "variable_bounds": { "upper_bounds": ["inf"