# AutoTuneMPC Base URL: https://api.autotunempc.com Site: https://autotunempc.com POST https://api.autotunempc.com/v1/solve costs $0.02 Base USDC. POST https://api.autotunempc.com/v1/autotune costs $1.50. POST https://api.autotunempc.com/v1/templates/autotune costs $2.00. POST https://api.autotunempc.com/v1/validate is free. GET https://api.autotunempc.com/health is free. The Early Hardware Builder Pack is $15.00 one-time and sends header X-API-Key. Official x402 clients default to a $1.00 max payment, so POST https://api.autotunempc.com/v1/solve at $0.02 works by default. The $1.50 and $2.00 routes need the client limit raised to about $2.50, or an X-API-Key from https://autotunempc.com. A free POST https://api.autotunempc.com/v1/validate before paying rejects a bad plant without a charge. Callers send their own linear A and B, discrete or continuous, one of fourteen registered plants (double_integrator, thermal_rc_zone, soil_moisture_cascade, cart_pendulum, unicycle_kinematics, gravity_tank, icr_skid_steer, ackermann, quadrotor_3d, thermal_valve_process, marine_usv, anti_sway_crane, process_valve, and quadrotor), or a kind expression plant with one allowlisted scalar expression per state row. unicycle_kinematics, gravity_tank, icr_skid_steer, ackermann, quadrotor_3d, thermal_valve_process, marine_usv, anti_sway_crane, process_valve, and quadrotor are nonlinear. cart_pendulum is the upright linearization. Expressions outside that allowlist are rejected. The hosted API at autotunempc.com runs IPOPT. OSQP is an opt-in quadratic solver on that same host. acados SQP and SQP-RTI are an opt-in C-codegen backend for a local or self-hosted build, not the hosted API. Optional h rows are h(x, u, p) <= 0, at most 8. Obstacle slots are cx, cy, r, and active, at most 8, and they do not count against np. The circle row is active times (r squared minus squared distance), with no square root. A path frame names two position indexes and one heading index. The residuals are the along-track error, the cross-track error, sin of the heading error, and 1 minus cos of the heading error. One path sample, along, across, and heading, is required per state node. A zone band is two inequalities and one slack around one state, with no absolute value. At most 8 bands. The residual is the slack. A weight of 0 leaves the band unpaid. The three templates, differential_drive, battery_peak_shaving, and root_zone_irrigation, each run one fixed benchmark scenario. POST /v1/autotune accepts the same caller models as POST /v1/solve. POST /v1/autotune tunes on the single scenario in the request. It has no scenario bank and no never-worse check, so the result is the best trial of that study, not a comparison with weights you already have. An optional curriculum field is declarative JSON only: 1 to 4 stages, 1 to 12 training scenarios and 1 to 12 cap scenarios per stage, 1 to 12 held-out scenarios that are not also training or cap rows, at most 40 steps on each curriculum rollout, at most 40 trials in a stage and at most 40 trials in total, and one timeout greater than 0 seconds and at most 120 seconds. The verdict applies only to the supplied scenarios. Offline tuning and simulation. A remote API is not a hardware safety loop. Card checkout buys a prepaid pack (250 solves + 10 autotunes). x402 is pay-per-call in USDC on Base with no account. HTTP 200 spends a solve credit, including status infeasible, suboptimal_timeout, suboptimal_acceptable and suboptimal_inaccurate. HTTP 422 does not spend a credit. An accepted POST /v1/autotune spends one autotune credit. A full queue is HTTP 429 and is not charged. A template autotune spends one autotune credit. The template study uses a fixed sampler seed of 7. The API does not accept a seed. The MCP tool autotune_embedded_controller_with_c_codegen costs $2.00 and spends 1 autotune credit. It is not a separate HTTP route. battery_peak_shaving reports three peak-window means in kW. peak_grid_kw uses the tuned weights. flat_hold_peak_grid_kw is demand with no battery command. peak_grid_kw_fixed uses Q=0.02, R=25, Rd=0.01, Qf=0.02. POST https://api.autotunempc.com/v1/validate body for the page's double integrator: { "system": { "kind": "nonlinear", "name": "double_integrator", "parameters": { "dt": 0.1 }, "N": 8, "u_min": [ -2.0 ], "u_max": [ 2.0 ], "du_min": [ -1.0 ], "du_max": [ 1.0 ] } } POST https://api.autotunempc.com/v1/export is free. No X-API-Key and no x402 charge. The response includes filename, usage, and a numbered instructions list. Do those steps in the folder where the file was saved. Each step is one command. Ubuntu and Debian block a plain pip install, so the steps create a .venv folder. target casadi_python writes mpc_controller.py. The steps are: python3 -m venv .venv, then .venv/bin/pip install casadi numpy, then .venv/bin/python mpc_controller.py. It prints a 50-step rollout. target ros2_node writes ros2_mpc_node.py. Source ROS, then python3 -m venv --system-site-packages .venv, then .venv/bin/pip install casadi numpy, then .venv/bin/python ros2_mpc_node.py. That simulates the plant on this computer. --live is the separate command for Gazebo or hardware. target acados_python writes build_and_run_acados.py. acados SQP is a different solver from the hosted IPOPT backend. IPOPT-tuned weights are unvalidated on acados until checked in closed loop on the target machine. The export body below is a kinematic icr_skid_steer approximation. Lateral velocity is slip times yaw rate. It ignores dynamic slip. POST https://api.autotunempc.com/v1/export body: { "target": "casadi_python", "system": { "kind": "nonlinear", "name": "icr_skid_steer", "parameters": { "dt": 0.1, "slip": 0.2 }, "N": 8, "u_min": [ 0.0, -1.2 ], "u_max": [ 1.2, 1.2 ], "du_min": [ -0.8, -0.8 ], "du_max": [ 0.8, 0.8 ] }, "x0": [ 0.0, 0.0, 0.0 ], "x_ref": [ 0.4, 0.0, 0.0 ], "Q": [ [ 4.0, 0.0, 0.0 ], [ 0.0, 4.0, 0.0 ], [ 0.0, 0.0, 4.0 ] ], "R": [ [ 0.2, 0.0 ], [ 0.0, 0.2 ] ], "Rd": [ [ 0.2, 0.0 ], [ 0.0, 0.2 ] ], "Qf": [ [ 8.0, 0.0, 0.0 ], [ 0.0, 8.0, 0.0 ], [ 0.0, 0.0, 8.0 ] ] } POST https://api.autotunempc.com/v1/sysid is free. No X-API-Key and no x402 charge. Send 4 to 2000 rows. Each row has t, u, and y. Timestamps strictly increase, and every row uses the same u and y widths. The response has A, B, dt, and fit_error. POST https://api.autotunempc.com/v1/sysid body: { "samples": [ { "t": 0.0, "u": [ 0.0 ], "y": [ 0.2, 0.2 ] }, { "t": 0.5, "u": [ 0.6 ], "y": [ 0.24, 0.21 ] }, { "t": 1.0, "u": [ 0.0 ], "y": [ 0.23, 0.22 ] }, { "t": 1.5, "u": [ 0.6 ], "y": [ 0.26, 0.23 ] }, { "t": 2.0, "u": [ 0.0 ], "y": [ 0.25, 0.23 ] } ] } POST https://api.autotunempc.com/v1/solve body, the same plant as the page: { "system": { "kind": "nonlinear", "name": "double_integrator", "parameters": { "dt": 0.1 }, "N": 8, "u_min": [ -2.0 ], "u_max": [ 2.0 ], "du_min": [ -1.0 ], "du_max": [ 1.0 ] }, "x0": [ 0.0, 0.0 ], "x_ref": [ 0.4, 0.0 ], "Q": [ [ 10.0, 0.0 ], [ 0.0, 2.0 ] ], "R": [ [ 0.1 ] ], "Rd": [ [ 0.1 ] ], "Qf": [ [ 20.0, 0.0 ], [ 0.0, 4.0 ] ] } POST https://api.autotunempc.com/v1/solve response from a local run of that body. u0 is the first input. solve_time_ms is the solver timer for that call and is omitted here because it changes from call to call: { "success": true, "status": "optimal", "u0": [ 0.999999523855359 ] } POST https://api.autotunempc.com/v1/templates/autotune body: { "name": "battery_peak_shaving", "max_trials": 2 } POST /v1/templates/autotune returns the tuned weights in that response. POST /v1/autotune returns a job id and, when a pack key is in use, a job token. Poll GET https://api.autotunempc.com/v1/jobs/{job_id} with header X-Job-Token set to that job token until status is complete or failed. claude mcp add --transport http autotunempc https://api.autotunempc.com/mcp {"mcpServers":{"autotunempc":{"type":"http","url":"https://api.autotunempc.com/mcp"}}}