# Indexes
(*indexes*)

## Overview

### Available Operations

* [list](#list) - List indexes within a project
* [create](#create) - Create an index
* [delete](#delete) - Delete an index
* [get](#get) - Get an index
* [ask](#ask) - Ask a question to an index

## list

Retrieve a list of all created indexes.

### Example Usage

<!-- UsageSnippet language="typescript" operationID="listIndexes" method="get" path="/v1/indexes" -->
```typescript
import { Ducky } from "duckyai-ts";

const ducky = new Ducky({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const result = await ducky.indexes.list();

  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { DuckyCore } from "duckyai-ts/core.js";
import { indexesList } from "duckyai-ts/funcs/indexesList.js";

// Use `DuckyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ducky = new DuckyCore({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const res = await indexesList(ducky);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("indexesList failed:", res.error);
  }
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `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](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ListIndexesResponse](../../models/components/listindexesresponse.md)\>**

### Errors

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

## create

Create a new index to organize and store documents or items from integrations.

### Example Usage

<!-- UsageSnippet language="typescript" operationID="createIndex" method="post" path="/v1/indexes" -->
```typescript
import { Ducky } from "duckyai-ts";

const ducky = new Ducky({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const result = await ducky.indexes.create({
    indexName: "index_name",
  });

  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { DuckyCore } from "duckyai-ts/core.js";
import { indexesCreate } from "duckyai-ts/funcs/indexesCreate.js";

// Use `DuckyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ducky = new DuckyCore({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const res = await indexesCreate(ducky, {
    indexName: "index_name",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("indexesCreate failed:", res.error);
  }
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [components.CreateIndexRequest](../../models/components/createindexrequest.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](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.CreateIndexResponse](../../models/components/createindexresponse.md)\>**

### Errors

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

## delete

Delete a specific index by providing its unique identifier.

### Example Usage

<!-- UsageSnippet language="typescript" operationID="deleteIndex" method="delete" path="/v1/indexes/{index_name}" -->
```typescript
import { Ducky } from "duckyai-ts";

const ducky = new Ducky({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  await ducky.indexes.delete({
    indexName: "<value>",
  });


}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { DuckyCore } from "duckyai-ts/core.js";
import { indexesDelete } from "duckyai-ts/funcs/indexesDelete.js";

// Use `DuckyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ducky = new DuckyCore({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const res = await indexesDelete(ducky, {
    indexName: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("indexesDelete failed:", res.error);
  }
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.DeleteIndexRequest](../../models/operations/deleteindexrequest.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](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<void\>**

### Errors

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

## get

Get the details of an index by index name.

### Example Usage

<!-- UsageSnippet language="typescript" operationID="getIndex" method="get" path="/v1/indexes/{index_name}" -->
```typescript
import { Ducky } from "duckyai-ts";

const ducky = new Ducky({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const result = await ducky.indexes.get({
    indexName: "<value>",
  });

  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { DuckyCore } from "duckyai-ts/core.js";
import { indexesGet } from "duckyai-ts/funcs/indexesGet.js";

// Use `DuckyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ducky = new DuckyCore({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const res = await indexesGet(ducky, {
    indexName: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("indexesGet failed:", res.error);
  }
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.GetIndexRequest](../../models/operations/getindexrequest.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](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.GetIndexResponse](../../models/components/getindexresponse.md)\>**

### Errors

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

## ask

Ask a natural language question and get a synthesized answer from documents in the index

### Example Usage

<!-- UsageSnippet language="typescript" operationID="askIndex" method="post" path="/v1/indexes/{index_name}/ask" -->
```typescript
import { Ducky } from "duckyai-ts";

const ducky = new Ducky({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const result = await ducky.indexes.ask({
    indexName: "<value>",
    askIndexRequest: {
      question: "question",
      threadId: "thread_id",
    },
  });

  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { DuckyCore } from "duckyai-ts/core.js";
import { indexesAsk } from "duckyai-ts/funcs/indexesAsk.js";

// Use `DuckyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ducky = new DuckyCore({
  apiKey: process.env["DUCKY_API_KEY"] ?? "",
});

async function run() {
  const res = await indexesAsk(ducky, {
    indexName: "<value>",
    askIndexRequest: {
      question: "question",
      threadId: "thread_id",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("indexesAsk failed:", res.error);
  }
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.AskIndexRequest](../../models/operations/askindexrequest.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](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.AskIndexResponse](../../models/components/askindexresponse.md)\>**

### Errors

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