Skip to main content
Use the TypeScript SDK to connect a provider account, save a model, submit a run (one task you send to Millwork; the API calls it an execution), and read its result and receipt. It provides typed requests and responses for TypeScript and JavaScript on Node.js.

Install

Requires Node.js 20 or later (Millwork tests 20 and 22) and an organization API key.
The package is @millwork/solver on npm. Version 0.1.3 also includes the millwork command-line tool, which 0.1.0 and 0.1.1 do not carry. The tool reads SOLVERAPI_API_KEY and SOLVERAPI_BASE_URL rather than the two variables this example names; Set up with the CLI covers it.

Make a test run

The example reads two variables you set yourself; the client takes the key and base URL as arguments. Use your organization API key and https://api.getmillwork.dev/v1. Save it as example.mts and run it with npx tsx example.mts. The package is ESM only, so a JavaScript copy needs "type": "module" in your package.json. API basics explains authentication. This example submits a test run and reads its receipt without calling a model.
A test run (the API calls it Echo, mode: "echo") has no platform fee or model cost. It takes no output check, a check applied to a run’s output, so the example omits verifier_id.

What the client does

You construct one Solver with apiKey and baseUrl. The client never changes the base URL you give it. Each resource below calls one API endpoint and returns the response typed. A saved model is an arm in the API, an output check is a verifier, and an organization is a tenant. Run submission takes a request key, sent as the Idempotency-Key header. You own the key; the client forwards it unchanged, so a retry with the same key returns the same run instead of starting a second one. Most other writes accept a request key as an option. The client offers no request-key option for cancel, proposal decisions, and template plans, so each of those gets one attempt. Template apply and template resume require a request key. The client retries on its own only when a replay cannot apply work twice: a read, or a write that carries your request key. It retries those after a network failure or a 5xx response, up to two more attempts by default (maxRetries), with exponential backoff from 500 ms (retryBackoffMs), and replays the same bytes each time. It never retries a 4xx response, and a write without a request key gets exactly one attempt.

Errors

Every non-2xx response throws SolverApiError. It carries the API’s error object as fields, so you never parse the message: type (the error code), status, detail, instance, errors (per-field messages, when present), and retryAfterS (the seconds to wait, when the API sends one). A network failure, or an error response whose body is not valid JSON, throws SolverApiNetworkError with the underlying cause. Errors and retries lists each error code and the next step.

API basics

The base URL, bearer authentication, request keys, polling, and the error format.

Make your first API call

Send a free test run with curl and read its receipt.