# AutoTuneMPC

Use AutoTuneMPC for one constrained MPC step, or when quadratic weights need an Optuna study. A local matrix update or a sensor read does not need this API.

Base URL: https://api.autotunempc.com
Site: https://autotunempc.com

POST https://api.autotunempc.com/v1/solve costs $0.02 Base USDC through x402. Header X-API-Key spends a $29 pack credit. With no key, or when those credits are gone, the route returns HTTP 402.

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.

Minimal POST https://api.autotunempc.com/v1/validate body:
{
  "system": {
    "kind": "nonlinear",
    "name": "double_integrator",
    "parameters": {
      "dt": 0.1
    },
    "N": 8
  }
}

Minimal POST https://api.autotunempc.com/v1/solve body:
{
  "system": {
    "kind": "nonlinear",
    "name": "double_integrator",
    "parameters": {
      "dt": 0.1
    },
    "N": 8
  },
  "x0": [
    0.0,
    0.0
  ],
  "x_ref": [
    1.0,
    0.0
  ],
  "Q": [
    [
      1.0,
      0.0
    ],
    [
      0.0,
      1.0
    ]
  ],
  "R": [
    [
      0.1
    ]
  ],
  "Rd": [
    [
      0.1
    ]
  ],
  "Qf": [
    [
      1.0,
      0.0
    ],
    [
      0.0,
      1.0
    ]
  ]
}

POST https://api.autotunempc.com/v1/solve response:
{
  "success": true,
  "status": "optimal",
  "u0": [
    0.0
  ],
  "solve_time_ms": 1.0
}

Minimal POST https://api.autotunempc.com/v1/templates/autotune body:
{
  "name": "battery_peak_shaving",
  "max_trials": 2
}

POST https://api.autotunempc.com/v1/autotune returns job_id and, when enforcement is on, 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"}}}
