Skip to main content
skill CX Codex

cuopt-routing-api-python — Claude Code skill for cuOpt routing

A skill that walks your agent through vehicle routing with the cuOpt Python API: TSP, VRP and pickup-delivery. Useful when the solver runs in Python.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a claude-code
Open on GitHub

What cuopt-routing-api-python does

The skill covers cuOpt routing through Python only. There is no C API for routing in cuOpt, so code in another language is out of scope. Inside you get a minimal VRP example built on cudf and cuopt.routing, plus sections on constraints and solution checking.

Before writing code, the agent asks for the problem type (TSP, VRP or PDP), the number of locations and depots, the cost or distance matrix, orders with their demand, the fleet with capacity and start/end points, and constraints such as time windows or precedence. Then it builds a DataModel, attaches matrices and calls routing.Solve with SolverSettings.

Matrices and series need explicit dtypes (float32, int32) because silent errors slip through otherwise. When the status is not 0, the skill points you at get_error_message() and the list of infeasible orders. One trap worth knowing: compute_waypoint_sequence rewrites the location column of route_df in place, so pass route_df.copy() if you still need cost-matrix indices while iterating per truck.

What it helps with

  • build a VRP model from a cost matrix and a fleet
  • attach time windows and service times to orders
  • set capacity across several dimensions
  • link pickup-delivery pairs and order precedence
  • debug an empty solution or an infeasible order

Example prompts for the agent

  • Solve a VRP with 4 locations and 2 vehicles, cost matrix in cudf
  • Add time windows and weight capacity to the cuOpt model
  • Status is not 0 — print the infeasible orders and the error message

How to install cuopt-routing-api-python

1Skills CLI (Vercel)

npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a claude-code

2Manually: put the files in place

~/.claude/skills/cuopt-routing-api-python/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cuopt-routing-api-python/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cuopt-routing-api-python

How do I install cuopt-routing-api-python in Claude?

Run npx skills add NVIDIA/skills --skill cuopt-routing-api-python -a claude-code. The skill file then lives at ~/.claude/skills/cuopt-routing-api-python/SKILL.md.

What does cuopt-routing-api-python do?

It guides the agent through building and solving vehicle routing problems with the cuOpt Python API: TSP, VRP and pickup-delivery, with time and capacity constraints.

Why is my solution empty or an order marked infeasible?

The skill suggests widening time windows, checking travel times, or increasing fleet size and capacity. With time windows set, you need a transit time matrix via add_transit_time_matrix().

Source text

SKILL.md · Apache-2.0
---
name: cuopt-routing-api-python
version: "26.10.00"
description: Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python.
license: Apache-2.0
metadata:
  author: NVIDIA cuOpt Team
  tags:
    - cuopt
    - routing
    - vrp
    - tsp
    - python
---




# cuOpt Routing — Python API

This skill is **Python only**. Routing has no C API in cuOpt.

## Required questions

Ask these if not already clear:

1. **Problem type** — TSP, VRP, or PDP?
2. **Locations** — How many? Depot(s)? Cost or distance between pairs (matrix or derived)?
3. **Orders / tasks** — Which locations must be visited? Demand or service per stop?
4. **Fleet** — Number of vehicles, capacity per vehicle (and per dimension if multiple), start/end locations?
5. **Constraints** — Time windows (earliest/latest arrival), service times, precedence (order A before B)?

## Minimal VRP Example

```python
import cudf
from cuopt import routing

cost_matrix = cudf.DataFrame([...], dtype="float32")
dm = routing.DataModel(n_locations=4, n_fleet=2, n_orders=3)
dm.add_cost_matrix(cost_matrix)
dm.set_order_locations(cudf.Series([1, 2, 3], dtype="int32"))
solution = routing.Solve(dm, routing.SolverSettings())

if solution.get_status() == 0:
    solution.display_routes()
```

## Adding Constraints

```python
# Time windows
dm.add_transit_time_matrix(transit_time_matrix)
dm.set_order_time_windows(earliest_series, latest_series)

# Capacities
dm.add_capacity_dimension("weight", demand_series, capacity_series)
dm.set_order_service_times(service_times)
dm.set_vehicle_locations(start_locations, end_locations)
dm.set_vehicle_time_windows(earliest_start, latest_return)

# Pickup-delivery pairs
dm.set_pickup_delivery_pairs(pickup_indices, delivery_indices)

# Precedence
dm.add_order_precedence(node_id=2, preceding_nodes=np.array([0, 1]))
```

## Solution Checking

```python
status = solution.get_status()  # 0=SUCCESS, 1=FAIL, 2=TIMEOUT, 3=EMPTY
if status == 0:
    route_df = solution.get_route()
    total_cost = solution.get_total_objective()
else:
    print(solution.get_error_message())
    print(solution.get_infeasible_orders().to_list())
```

## Data Types (use explicit dtypes)

```python
cost_matrix = cost_matrix.astype("float32")
order_locations = cudf.Series([...], dtype="int32")
demand = cudf.Series([...], dtype="int32")
```

## Solver Settings

```python
ss = routing.SolverSettings()
ss.set_time_limit(30)
ss.set_verbose_mode(True)
ss.set_error_logging_mode(True)
```

## Common Issues

| Problem | Fix |
|---------|-----|
| Empty solution | Widen time windows or check travel times |
| Infeasible orders | Increase fleet or capacity |
| Status != 0 with time windows | Add `add_transit_time_matrix()` |
| Wrong cost | Check cost_matrix is symmetric |
| `compute_waypoint_sequence` alters route_df | It replaces the `location` column with waypoint ids in place — pass `route_df.copy()` if you still need cost-matrix indices (e.g. when iterating per truck) |

## Debugging

**When status != 0:** `print(solution.get_error_message())` and `print(solution.get_infeasible_orders().to_list())` to see which orders are infeasible.

**Data types:** Use explicit dtypes (float32, int32) for matrices and series to avoid silent errors.

## Examples

- [examples.md](references/examples.md) — VRP, PDP, multi-depot
- [server_examples.md](references/server_examples.md) — REST client (curl, Python)
- **Reference models:** This skill's `assets/` — [vrp_basic](assets/vrp_basic/), [pdp_basic](assets/pdp_basic/). See [assets/README.md](assets/README.md).

## Escalate

For contribution or build-from-source, see the developer skill.

© NVIDIA cuOpt Team · Apache-2.0 · NVIDIA/skills

Similar skills

Everything for AI and ML →

From the same set178

data-designer Creates synthetic datasets and Python data-generation pipelines with Data Designer. Use it when you need to describe a dataset and turn that description into a script. CX Codex +1 2,500installs deepstream-dev Teaches the agent to write NVIDIA DeepStream SDK code in Python: GStreamer pipelines, TensorRT inference, tracking and broker output. CX Codex +1 2,400installs nemo-retriever Indexes and queries document collections using the NeMo Retriever 26.8.1 CLI. Useful for local LanceDB storage and deployed Retriever services. CX Codex +1 2,400installs rag-eval Evaluates filesystem RAG datasets built around corpus/ and train.json. Use it to compare retrieval and generation settings with RAGAS quality scores. CX Codex +1 2,400installs dynamo-recipe-runner Discovers, validates, patches, and deploys NVIDIA Dynamo Kubernetes recipes for model serving across vLLM or SGLang runtimes. CX Codex +1 2,300installs deepstream-import-vision-model This skill takes an object-detection model from HuggingFace or NGC through a full NVIDIA DeepStream pipeline: ONNX, TRT engine, bbox parser, benchmark, PDF report. CX Codex +1 2,300installs omniverse-usd-performance-tuning A skill for diagnosing and optimizing USD scenes: slow loading, low FPS, high memory. It owns the user-facing workflow across phases. CX Codex +1 2,300installs cuopt-server-api-python Deploys the NVIDIA cuOpt REST server and guides client requests via Python or curl. Useful for solving routing, LP, and MILP optimization problems on GPUs. CX Codex +1 2,200installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor