> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lucid.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# ZKML SDK

> Zero-knowledge ML — prove inference, verify proofs, register models on-chain

# ZKML SDK

Zero-knowledge ML — prove inference, verify proofs, register models on-chain

## Operations

| Method                   | Description                    |
| ------------------------ | ------------------------------ |
| `lucidGenerateZkmlProof` | Generate zkML proof            |
| `lucidVerifyZkmlProof`   | Verify zkML proof              |
| `lucidRegisterZkmlModel` | Register model circuit         |
| `lucidListZkmlModels`    | List registered model circuits |

## Generated Reference

### Overview

Zero-knowledge ML — prove inference, verify proofs, register models on-chain

#### Available Operations

* [lucidGenerateZkmlProof](#lucidgeneratezkmlproof) - Generate zkML proof
* [lucidVerifyZkmlProof](#lucidverifyzkmlproof) - Verify zkML proof
* [lucidRegisterZkmlModel](#lucidregisterzkmlmodel) - Register model circuit
* [lucidListZkmlModels](#lucidlistzkmlmodels) - List registered model circuits

### lucidGenerateZkmlProof

Generate a zero-knowledge proof for a model inference run. The proof attests that a specific model produced a specific output without revealing the model weights or full input.

#### Example Usage

```typescript theme={null}
import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const raijinLabsLucidAi = new RaijinLabsLucidAi();

async function run() {
  const result = await raijinLabsLucidAi.zkML.lucidGenerateZkmlProof({
    modelId: "<id>",
    inputHash: "<value>",
    outputHash: "<value>",
    policyHash: "<value>",
  });

  console.log(result);
}

run();
```

#### Standalone function

The standalone function version of this method:

```typescript theme={null}
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { zkMLLucidGenerateZkmlProof } from "raijin-labs-lucid-ai/funcs/zkMLLucidGenerateZkmlProof.js";

// Use `RaijinLabsLucidAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raijinLabsLucidAi = new RaijinLabsLucidAiCore();

async function run() {
  const res = await zkMLLucidGenerateZkmlProof(raijinLabsLucidAi, {
    modelId: "<id>",
    inputHash: "<value>",
    outputHash: "<value>",
    policyHash: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("zkMLLucidGenerateZkmlProof failed:", res.error);
  }
}

run();
```

#### Parameters

| Parameter              | Type                                                                                                                                      | Required             | Description                                                                                                                                                                    |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`              | [models.GenerateZkMLProofRequest](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/generatezkmlproofrequest.md) | :heavy\_check\_mark: | The request object to use for the request.                                                                                                                                     |
| `options`              | RequestOptions                                                                                                                            | :heavy\_minus\_sign: | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                   | :heavy\_minus\_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`      | [RetryConfig](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/lib/utils/retryconfig.md)                               | :heavy\_minus\_sign: | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

#### Response

**Promise\<[operations.LucidGenerateZkmlProofResponse](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/operations/lucidgeneratezkmlproofresponse.md)>**

#### Errors

| Error Type                           | Status Code | Content Type     |
| ------------------------------------ | ----------- | ---------------- |
| errors.ErrorResponse                 | 400         | application/json |
| errors.ErrorResponse                 | 500         | application/json |
| errors.RaijinLabsLucidAiDefaultError | 4XX, 5XX    | \*/\*            |

### lucidVerifyZkmlProof

Verify a zkML Groth16 proof. Performs off-chain verification first, then optionally submits for on-chain verification via the ecPairing precompile on EVM chains.

#### Example Usage

```typescript theme={null}
import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const raijinLabsLucidAi = new RaijinLabsLucidAi();

async function run() {
  const result = await raijinLabsLucidAi.zkML.lucidVerifyZkmlProof({
    chainId: "<id>",
    proof: {},
    receiptHash: "<value>",
  });

  console.log(result);
}

run();
```

#### Standalone function

The standalone function version of this method:

```typescript theme={null}
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { zkMLLucidVerifyZkmlProof } from "raijin-labs-lucid-ai/funcs/zkMLLucidVerifyZkmlProof.js";

// Use `RaijinLabsLucidAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raijinLabsLucidAi = new RaijinLabsLucidAiCore();

async function run() {
  const res = await zkMLLucidVerifyZkmlProof(raijinLabsLucidAi, {
    chainId: "<id>",
    proof: {},
    receiptHash: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("zkMLLucidVerifyZkmlProof failed:", res.error);
  }
}

run();
```

#### Parameters

| Parameter              | Type                                                                                                                                  | Required             | Description                                                                                                                                                                    |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`              | [models.VerifyZkMLProofRequest](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/verifyzkmlproofrequest.md) | :heavy\_check\_mark: | The request object to use for the request.                                                                                                                                     |
| `options`              | RequestOptions                                                                                                                        | :heavy\_minus\_sign: | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                               | :heavy\_minus\_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`      | [RetryConfig](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/lib/utils/retryconfig.md)                           | :heavy\_minus\_sign: | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

#### Response

**Promise\<[models.ZkMLVerifyResponse](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/zkmlverifyresponse.md)>**

#### Errors

| Error Type                           | Status Code | Content Type     |
| ------------------------------------ | ----------- | ---------------- |
| errors.ErrorResponse                 | 400         | application/json |
| errors.ErrorResponse                 | 500         | application/json |
| errors.RaijinLabsLucidAiDefaultError | 4XX, 5XX    | \*/\*            |

### lucidRegisterZkmlModel

Register a model's Groth16 verifying key on-chain, enabling future proofs for this model to be verified by the ZkMLVerifier smart contract.

#### Example Usage

```typescript theme={null}
import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const raijinLabsLucidAi = new RaijinLabsLucidAi();

async function run() {
  const result = await raijinLabsLucidAi.zkML.lucidRegisterZkmlModel({
    chainId: "<id>",
    modelHash: "<value>",
    verifyingKey: "<value>",
  });

  console.log(result);
}

run();
```

#### Standalone function

The standalone function version of this method:

```typescript theme={null}
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { zkMLLucidRegisterZkmlModel } from "raijin-labs-lucid-ai/funcs/zkMLLucidRegisterZkmlModel.js";

// Use `RaijinLabsLucidAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raijinLabsLucidAi = new RaijinLabsLucidAiCore();

async function run() {
  const res = await zkMLLucidRegisterZkmlModel(raijinLabsLucidAi, {
    chainId: "<id>",
    modelHash: "<value>",
    verifyingKey: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("zkMLLucidRegisterZkmlModel failed:", res.error);
  }
}

run();
```

#### Parameters

| Parameter              | Type                                                                                                                                      | Required             | Description                                                                                                                                                                    |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`              | [models.RegisterZkMLModelRequest](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/registerzkmlmodelrequest.md) | :heavy\_check\_mark: | The request object to use for the request.                                                                                                                                     |
| `options`              | RequestOptions                                                                                                                            | :heavy\_minus\_sign: | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                   | :heavy\_minus\_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`      | [RetryConfig](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/lib/utils/retryconfig.md)                               | :heavy\_minus\_sign: | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

#### Response

**Promise\<[models.SuccessResponse](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/successresponse.md)>**

#### Errors

| Error Type                           | Status Code | Content Type     |
| ------------------------------------ | ----------- | ---------------- |
| errors.ErrorResponse                 | 400         | application/json |
| errors.ErrorResponse                 | 500         | application/json |
| errors.RaijinLabsLucidAiDefaultError | 4XX, 5XX    | \*/\*            |

### lucidListZkmlModels

List all registered zkML model circuits on a specific chain, including model IDs, verifying key hashes, and registration timestamps.

#### Example Usage

```typescript theme={null}
import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const raijinLabsLucidAi = new RaijinLabsLucidAi();

async function run() {
  const result = await raijinLabsLucidAi.zkML.lucidListZkmlModels({
    chainId: "<id>",
  });

  console.log(result);
}

run();
```

#### Standalone function

The standalone function version of this method:

```typescript theme={null}
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { zkMLLucidListZkmlModels } from "raijin-labs-lucid-ai/funcs/zkMLLucidListZkmlModels.js";

// Use `RaijinLabsLucidAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raijinLabsLucidAi = new RaijinLabsLucidAiCore();

async function run() {
  const res = await zkMLLucidListZkmlModels(raijinLabsLucidAi, {
    chainId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("zkMLLucidListZkmlModels failed:", res.error);
  }
}

run();
```

#### Parameters

| Parameter              | Type                                                                                                                                                         | Required             | Description                                                                                                                                                                    |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`              | [operations.LucidListZkmlModelsRequest](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/operations/lucidlistzkmlmodelsrequest.md) | :heavy\_check\_mark: | The request object to use for the request.                                                                                                                                     |
| `options`              | RequestOptions                                                                                                                                               | :heavy\_minus\_sign: | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                      | :heavy\_minus\_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`      | [RetryConfig](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/lib/utils/retryconfig.md)                                                  | :heavy\_minus\_sign: | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

#### Response

**Promise\<[models.ListZkMLModelsResponse](https://github.com/lucid-fdn/lucid-ai-sdk/blob/main/typescript/docs/models/listzkmlmodelsresponse.md)>**

#### Errors

| Error Type                           | Status Code | Content Type     |
| ------------------------------------ | ----------- | ---------------- |
| errors.ErrorResponse                 | 500         | application/json |
| errors.RaijinLabsLucidAiDefaultError | 4XX, 5XX    | \*/\*            |
