> ## Documentation Index
> Fetch the complete documentation index at: https://eddy-ac74d702.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript

> npm install @eddy-solve/client

```bash theme={null}
npm install @eddy-solve/client
```

ESM and CommonJS builds with type declarations; no dependencies — `fetch` from Node 18+ or the browser.

## The smallest complete solve

```ts theme={null}
import { Eddy } from "@eddy-solve/client";

const eddy = new Eddy({ baseUrl: "http://127.0.0.1:8080", apiKey: undefined });
const result = await eddy.solveStructural({
  geometry: { primitive: { box: { lx: 1.0, ly: 0.2, lz: 0.2 } } },
  material: { id: "steel", e: 210e9, nu: 0.3, rho: 7850, yield: 250e6 },
  loads: [{ region: "x_max", force: [0, 0, -1000] }],
  constraints: [{ region: "x_min", fixed: "all" }],
  mesh_opts: { element_size: 0.1 },
});
console.log(result.result_id, result.cached, result.metrics);
const u = await eddy.field(result, "displacement"); // { components: 3, count, values: Float64Array }
console.log(u.count, "nodes, max |u| =", u.maxMagnitude());
```

## Errors

Every failure rejects with an `EddyError` carrying `.code` (the API's error code), `.message` and `.status` (the HTTP status; `0` for a client-side `TRANSPORT` / `TIMEOUT`).

## Async jobs

A `202` is followed through `poll` to the result by default; pass `{ wait: false }` as the call's options to get the handle, then `await eddy.waitForJob(job)` or `for await (const [event, status] of eddy.jobEvents(job.job_id)) ...`.

## Blobs and fields

`eddy.blob(id)` fetches bytes through a `BlobCache` (in-memory by default; `fileBlobCache(dir)` from `@eddy-solve/client/node` persists to a directory — a blob id names its bytes forever). `eddy.field(result, "displacement")` decodes an `SSFLD1` blob into `{ components, count, values: Float64Array }`.

## Webhooks, usage and limits

An async solve can carry `webhook: { url, secret }` — the engine POSTs the finished job record to `url`, signed (`x-eddy-signature: blake3=<hex>`, a keyed BLAKE3 MAC over the body), three attempts, the delivery log on the job record (`(await eddy.getJob(id)).webhook`). `eddy.usage()` is the caller's own meter (the events under the presented key, the summed cost). A `429` is retried only when it carries `retry-after` (a rate limit); once the retries are spent a `429` / `503` rejects with `.retryAfter` — the seconds the engine asked for. The conventions for one key per tenant are on the [tenancy page](https://eddy-ac74d702.mintlify.site/sdks/tenancy.md).

## In a page

Every engine serves its own client: `<script src="/sdk/eddy.global.js"></script>` defines `globalThis.EddySDK` (`new EddySDK.Eddy({ baseUrl: "" })` talks to the engine that served the page); `/sdk/eddy.mjs`, `/sdk/eddy.cjs` and `/sdk/eddy.d.ts` are the module builds. The engine's own pages are consumers of it.

## Reference

One method per operation, named by the operation id — the [API reference](https://eddy-ac74d702.mintlify.site/api-reference) names each. Path parameters are positional, then the JSON body (typed by its request interface; extra keys pass through), then `query`, then the call options (`{ wait, signal, timeoutMs }`). `request(method, path, { json, data, contentType, query, admin, accepted, idempotent, options })` is the untyped escape hatch the typed methods share.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.