> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload Custom Index

> [!NOTE]
>
> **[Click for Python SDK](https://docs.nucleus.scale.com/en/latest/api/nucleus/index.html#nucleus.Dataset.create_custom_index)**
>
> ```
> Dataset.create_custom_index(
>     embeddings_urls: List[str],
>     embedding_dim: int
> ) -> AsyncJob
> ```

This endpoint allows users to upload custom image embedding vectors to use as the feature space for Autotag and similarity search.

A well-formed embeddings file must contain an entry for every image in the dataset, and all embeddings must have the same dimensions. A good embedding is a strong semantic descriptor for an image, usually a pre-activation output of a neural network layer.

## Formatting an Embedding File

The files must be in JSON format, and each file should contain no more than 5,000 embedding vectors.

The JSON objects are expected to have the following format: each key is a string `reference_id` uniquely identifying a DatasetItem, and each value is a list of floats. Numpy arrays must be converted to lists in order to serialize the JSON file.

The vectors must all have the same dimension/length.

The entries of the JSON object must be exhaustive, meaning that every Dataset Item in the dataset is represented in the keys. This implies that if your Dataset contains 5,000 images, the JSON object represented across the embedding files are also expected to have length 5,000.


## OpenAPI

````yaml openapi/nucleus.json POST /indexing/{dataset_id}
openapi: 3.1.0
info:
  title: Nucleus API
  version: '1.1'
servers:
  - url: https://api.scale.com/v1/nucleus
security:
  - sec0: []
paths:
  /indexing/{dataset_id}:
    post:
      summary: Upload Custom Index
      operationId: upload-custom-index
      parameters:
        - name: dataset_id
          in: path
          description: The Scale-generated ID of the Dataset.
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - embeddings_urls
                - embedding_dimension
              properties:
                embeddings_urls:
                  type: array
                  description: >-
                    Array of URLs each pointing to a JSON embeddings file. Each
                    JSON provides a mapping from `reference_id` to the
                    corresponding embedding vector. See [Formatting an Embedding
                    File](#formatting-an-embedding-file).
                  items:
                    type: string
                embedding_dimension:
                  type: integer
                  description: >-
                    The dimension of each embedding vector. All embeddings must
                    have the same dimension.
                  format: int32
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    dataset_id: ds_by0a81gnf6gfy9hw6rpg
                    job_id: job_c19xcf9mkws46gah00yg
                    job_last_known_status: Running
                    job_type: ingestTasks
                    job_creation_time: '2021-07-20T18:07:13.055Z'
                    message: >-
                      Processing embeddings in the background.  You can use the
                      job_id field to asynchronously check the status of this
                      indexing job.
              schema:
                type: object
                properties:
                  dataset_id:
                    type: string
                    example: ds_by0a81gnf6gfy9hw6rpg
                  job_id:
                    type: string
                    example: job_c19xcf9mkws46gah00yg
                  job_last_known_status:
                    type: string
                    example: Running
                  job_type:
                    type: string
                    example: ingestTasks
                  job_creation_time:
                    type: string
                    example: '2021-07-20T18:07:13.055Z'
                  message:
                    type: string
                    example: >-
                      Processing embeddings in the background.  You can use the
                      job_id field to asynchronously check the status of this
                      indexing job.
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  value: {}
              schema:
                type: object
                properties: {}
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: http
      scheme: basic

````