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

# Add Index

> This endpoint creates an index for an app.

### Auth Headers

<ParamField required header="x-metal-api-key" type="string">
  An API key for your org.
</ParamField>

<ParamField required header="x-metal-client-id" type="string">
  A Client ID for your org.
</ParamField>

### Body

<ParamField body="model" type="string" placeholder="Embedding model used on your data." required>
  The Embedding Model to use. Can be either "text-embedding-ada-002", "clip", or "custom".
</ParamField>

<ParamField body="name" type="string" placeholder="name of the index" required>
  Name of the Index
</ParamField>

<ParamField optional body="datasource" type="string" placeholder="datasource id">
  Datasource ID to connect to the index.
</ParamField>

<ParamField optional default="HNSW" body="indexType" type="string" placeholder="FLAT or HNSW">
  Type of the index. `FLAT` or `HNSW`
</ParamField>

<ParamField optional body="dimensions" type="integer" min="3" placeholder="number of dimensions that the embeddings will have">
  This is only required if you are using a "custom" model.
</ParamField>

<ParamField optional body="filters" type="object[]" placeholder="Metadata filters that the index can support for /search.">
  <Expandable title="properties">
    <ParamField body="field" type="string">
      The name of the filtereable field
    </ParamField>

    <ParamField body="type" type="string">
      The field type. Enum: `string` or `number`.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField optional body="chunkConfig" type="object" placeholder="Chunking configuration for data entity uploads.">
  <Expandable title="properties">
    <ParamField body="size" type="number" default={500}>
      The token size of each chunk.
    </ParamField>

    <ParamField body="overlap" type="number" default={20}>
      The token amount of overlap between chunks.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField optional body="tableChunkConfig" type="object" placeholder="Chunking configuration for data entity uploads that contain tables.">
  <Expandable title="properties">
    <ParamField body="size" type="number" default={4000}>
      The token size of each table chunk.
    </ParamField>
  </Expandable>
</ParamField>

### Response

<ResponseField name="data" type="Index Object">
  <Expandable title="properties">
    <ResponseField name="id" type="string">
      Id of the index
    </ResponseField>

    <ResponseField name="status" type="string">
      Status of the index
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the index
    </ResponseField>

    <ResponseField name="model" type="string">
      Model used to generate the embeddings
    </ResponseField>

    <ResponseField name="dimensions" type="number">
      Dimensions of the embeddings
    </ResponseField>

    <ResponseField name="chunkConfig" type="object" placeholder="Chunking configuration for data entity uploads.">
      <Expandable title="properties">
        <ResponseField name="size" type="number" default={500}>
          The token size of each chunk.
        </ResponseField>

        <ResponseField name="overlap" type="number" default={20}>
          The token amount of overlap between chunks.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="tableChunkConfig" type="object" placeholder="Chunking configuration for data entity uploads that contain tables.">
      <Expandable title="properties">
        <ResponseField name="size" type="number" default={4000}>
          The token size of each chunk.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash Example Request theme={null}
  curl --location --request POST 'https://api.getmetal.io/v1/indexes' \
  --header 'Content-Type: application/json' \
  --header 'x-metal-api-key: <api-key>' \
  --header 'x-metal-client-id: <client-id>' \
  --data-raw '{
      "model": "text-embedding-ada-002",
      "name": "Ozzy Osbourne",
      "filters": [
        {
          "field": "name",
          "type": "string"
        },
        {
          "field": "age",
          "type": "number"
        }
      ]
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
  	"data": {
  		"id": "1",
  		"createdAt": "2023-08-23T22:13:31.539Z",
  		"status": "LIVE",
  		"name": "Ozzy Osbourne",
  		"model": "text-embedding-ada-002",
  		"dimensions": 1536,
  		"filters": [
  			{
  				"field": "name",
  				"type": "string"
  			},
  			{
  				"field": "age",
  				"type": "number"
  			}
  		],
      "chunkConfig": {
        "size": 500,
        "overlap": 20
      },
      "tableChunkConfig": {
        "size": 4000
      },
  		"counts": {
  			"docs": 0,
  		}
  	}
  }
  ```
</ResponseExample>
