Route optimization
Send stops and constraints, get back an optimized, dispatch-ready route in seconds. Poll for it or have it pushed to your system.
Routing API · MCP server · Agent skill
Send stops from your code or your AI agent. Get back a dispatch-ready route in seconds, with geocoding in the same API.
https://r4m.ai/api/mcpWorks in Claude, ChatGPT, Cursor and VS Code. Setup per client →
plan the fastest route through these stops, leaving at 8
● r4m · create_optimizationGet started
Everything works the same two ways: an MCP server for your agents and a REST API for your code.
https://r4m.ai/api/mcpClaude, ChatGPT, Cursor and VS Code. Setup per client →
npx skills add r4m-ai/skillsYour agent learns when to plan a route itself and how to wire the SDK, keys and webhooks into your code. View on GitHub →
plan the fastest route through these stops, leaving at 8
> plan the fastest route through these stops, leaving at 8 ● r4m · create_optimization 5 addresses Depot 08:00 → 1155 Manhattan Ave → 1 Front St → 445 Albee Square W → 238 Bedford Ave → Depot 10:18 12.1 mi · 2 h 18 min · every stop fits
npm i @r4mai/sdkgo get github.com/r4m-ai/sdk-goThe call returns right away with an id. The solve keeps running on our side: queued, retried, monitored.
Signed webhooks, or fetch the result by id when you're ready. How the async flow works →
import { createClient } from "@r4mai/sdk"; const r4m = createClient({ apiKey: process.env.R4M_API_KEY!, }); // submit, answer the user at once await r4m.submitOptimization({ body: { addresses, webhookUrl }, }); // the plan arrives at your webhook POST /hooks/r4m optimization.completed
How it works
Send your stops, get back the order to drive them in. The SDKs wait out the solve for you. Over plain HTTP, poll for the result or have it pushed to your webhook.
POST /api/v1/optimizationsFrom code, the SDK or your AI agent. One request is all it takes.
202 Accepted · 2–60 sOptimization runs asynchronously on our side. Nothing for you to operate.
webhook or GET /{id}Pushed to your webhook, or fetched by id once the status is completed.
curl -X POST https://r4m.ai/api/v1/optimizations \
-H "Authorization: Bearer acc_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"addresses": [
{ "address": "Depot — 25 Kent Ave, Brooklyn, NY", "lat": 40.7218, "lng": -73.9615,
"isDepot": true, "serviceTimeSeconds": 900 },
{ "address": "1155 Manhattan Ave, Brooklyn, NY", "lat": 40.7304, "lng": -73.954,
"serviceTimeSeconds": 600, "timeWindowStart": "09:00", "timeWindowEnd": "10:30", "priority": 1 },
{ "address": "238 Bedford Ave, Brooklyn, NY", "lat": 40.7135, "lng": -73.967,
"serviceTimeSeconds": 900 },
{ "address": "1 Front St, Brooklyn, NY", "lat": 40.7033, "lng": -73.9881,
"serviceTimeSeconds": 600, "priority": 2 },
{ "address": "445 Albee Square W, Brooklyn, NY", "lat": 40.6926, "lng": -73.9873,
"serviceTimeSeconds": 1200 }
],
"parameters": { "travelMode": "driving", "optimizeMode": "Time", "roundTrip": true,
"routeStartAt": "2026-04-14T08:00", "timezone": "America/New_York" },
"webhookUrl": "https://your-server.com/webhooks/r4m"
}'
# 202 Accepted { "id": "550e8400-…", "status": "pending" }import { createClient } from "@r4mai/sdk";
const r4m = createClient({ apiKey: "acc_your_api_key" });
// Submits, waits out the solve, and hands back the finished plan.
// Pass a webhookUrl instead if you would rather be notified.
const { data: optimization, error } =
await r4m.createOptimizationAndWaitForRoutes({
body: {
addresses, // the five stops from the cURL tab
parameters: {
travelMode: "driving", optimizeMode: "Time", roundTrip: true,
routeStartAt: "2026-04-14T08:00", timezone: "America/New_York",
},
},
});
if (error) throw error;
console.log(optimization.result);client, err := r4m.New("acc_your_api_key")
if err != nil {
log.Fatal(err)
}
// Submits, waits out the solve, and hands back the finished plan.
// Set WebhookUrl instead if you would rather be notified.
optimization, err := client.CreateOptimizationAndWaitForRoutes(ctx,
r4m.CreateOptimizationRequest{
Addresses: addresses, // the five stops from the cURL tab
Parameters: &r4m.OptimizationParameters{
TravelMode: r4m.Ptr(r4m.Driving),
OptimizeMode: r4m.Ptr(r4m.Time),
RoundTrip: r4m.Ptr(true),
RouteStartAt: r4m.Ptr("2026-04-14T08:00"),
Timezone: r4m.Ptr("America/New_York"),
},
}, r4m.WaitOptions{}){
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"priceMicros": 25000,
"webhookStatus": "delivered",
"result": {
"routes": [
{
"routeStartAt": "2026-04-14T08:00:00-04:00",
"totalDistanceMeters": 19473,
"totalTimeSeconds": 8285,
"waypoints": [
{
"index": 0,
"arrivalAt": "2026-04-14T08:00:00-04:00",
"departureAt": "2026-04-14T08:15:00-04:00"
},
{
"index": 1,
"arrivalAt": "2026-04-14T09:00:00-04:00",
"waitTimeSeconds": 2543,
"cumulativeDistanceMeters": 1416
},
…
]
}
],
"unroutedStops": []
}
}
}Why r4m.ai
Every “optimize my route” feature sits on months of infrastructure that has nothing to do with your product. We run that layer as a service.
| Building it yourself | With r4m.ai | |
|---|---|---|
| Off-the-shelf solvers, far below state of the art | Powered by Route4Me algorithms, the company with the patents and over 17 years in the business | |
| An async engine with queues, retries and monitoring | One API call; we queue, retry and monitor | |
| Webhook delivery, result storage, status tracking | Results pushed to your webhook or fetched by id | |
| A geocoder that survives messy real-world addresses | Single and bulk geocoding in the same API | |
| Capacity planning for bursty, parallel load | No queue to run, no servers to scale; more in parallel by agreement | |
| Telematics integrations for every fleet vendor | Telematics in the same stack Soon |
The stack
Each capability is reachable the same two ways: the REST API for your code, the MCP server for your agents.
Send stops and constraints, get back an optimized, dispatch-ready route in seconds. Poll for it or have it pushed to your system.
Turn addresses into coordinates, one at a time or thousands in a single request. Forward and bulk, through the same API and MCP server.
Class 1–8 vehicle profiles, weight and dimension limits, hazardous-materials restrictions and commercial road rules.
Vehicle and fleet data in the same stack, without building and maintaining an integration for every telematics vendor.
For agents
Headless by design. Every capability works over the API and MCP server with no dashboard in the loop.
Point an agent at the MCP server or install the skill, and go from idea to a working routing prototype in a day.
add route planning to our dispatch app
Re-run identical scenarios to compare routing strategies, models and providers on equal terms.
re-run last month's routes with the new depot
Let agents explore what-if runs: fleet sizes, depots, time windows, delivery days.
try 4, 5 and 6 vans for Tuesday's stops
Turn address lists into dispatch-ready plans inside the workflows and tools you already use.
turn this address sheet into tomorrow's routes
Pricing
Spend from a prepaid balance that never expires. One price for every account, with no plan to choose.
Every new account starts with $1.00. No card required. The balance never expires.
Request size, rate and key limits are in the docs. Need more? Talk to us.
Create an account, grab a key, and give your team and your agents the whole geospatial stack. Start with $1.00 free.