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

# Generate Image Embedding

> Generate vector embeddings for images using multimodal models

<Info>
  **Product**: Visual Intelligence — Embeddings
  **Use case**: Generate vector embeddings for image, video, or text inputs for semantic search and similarity tasks
  **Host**: `https://mavi-backend.memories.ai/serve/api/v2`
  **Auth**: `Authorization: sk-mavi-...` (no `Bearer` prefix)
</Info>

This endpoint generates vector embeddings for images. You can either upload an image file directly or reference an existing asset by its ID.

<Note>
  **Pricing:**

  * \$0.0001 per image
</Note>

### Code Examples

<CodeGroup>
  ```javascript fetch (File Upload) theme={null}
  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const formData = new FormData();
  formData.append('file', imageFile);
  formData.append('model', 'multimodalembedding@001');

  const response = await fetch(`${BASE_URL}/embeddings/image`, {
    method: 'POST',
    headers: {
      'Authorization': API_KEY
    },
    body: formData
  });

  const data = await response.json();
  console.log(data);
  ```

  ```javascript fetch (Asset ID) theme={null}
  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const response = await fetch(`${BASE_URL}/embeddings/image`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': API_KEY
    },
    body: JSON.stringify({
      asset_id: 'imc_657766047105290240_15',
      model: 'multimodalembedding@001'
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```javascript axios (File Upload) theme={null}
  import axios from 'axios';

  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const formData = new FormData();
  formData.append('file', imageFile);
  formData.append('model', 'multimodalembedding@001');

  const response = await axios.post(`${BASE_URL}/embeddings/image`, formData, {
    headers: {
      'Authorization': API_KEY
    }
  });

  console.log(response.data);
  ```

  ```javascript axios (Asset ID) theme={null}
  import axios from 'axios';

  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const response = await axios.post(`${BASE_URL}/embeddings/image`, {
    asset_id: 'imc_657766047105290240_15',
    model: 'multimodalembedding@001'
  }, {
    headers: {
      'Authorization': API_KEY
    }
  });

  console.log(response.data);
  ```

  ```python Python (File Upload) theme={null}
  import requests

  BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2"
  API_KEY = "sk-mavi-..."
  HEADERS = {
      "Authorization": f"{API_KEY}"
  }

  def image_embedding_from_file(file_path, model="multimodalembedding@001"):
      url = f"{BASE_URL}/embeddings/image"
      data = {"model": model}
      files = {"file": open(file_path, "rb")}
      response = requests.post(url, headers=HEADERS, data=data, files=files)
      return response.json()

  # Usage example
  result = image_embedding_from_file("path/to/image.png", model="multimodalembedding@001")
  print(result)
  ```

  ```python Python (Asset ID) theme={null}
  import requests

  BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2"
  API_KEY = "sk-mavi-..."
  HEADERS = {
      "Authorization": f"{API_KEY}"
  }

  def image_embedding_from_asset(asset_id, model="multimodalembedding@001"):
      url = f"{BASE_URL}/embeddings/image"
      data = {"asset_id": asset_id, "model": model}
      response = requests.post(url, headers=HEADERS, json=data)
      return response.json()

  # Usage example
  result = image_embedding_from_asset("imc_657766047105290240_15", model="multimodalembedding@001")
  print(result)
  ```
</CodeGroup>

### Request Parameters

This endpoint supports two methods of providing images:

**Method 1: File Upload (multipart/form-data)**

| Field | Type   | Required | Description                                       |
| ----- | ------ | -------- | ------------------------------------------------- |
| file  | file   | Yes      | Image file to upload (JPEG, PNG, GIF, WebP, etc.) |
| model | string | Yes      | Embedding model name                              |

**Method 2: Asset ID (application/json)**

| Field     | Type   | Required | Description                                    |
| --------- | ------ | -------- | ---------------------------------------------- |
| asset\_id | string | Yes      | Existing image asset ID from a previous upload |
| model     | string | Yes      | Embedding model name                           |

**Supported Models:**

* `multimodalembedding@001` - Google's multimodal embedding model
* `mobileclip` - Efficient mobile-optimized CLIP model

### Response

Returns the embedding vector synchronously.

<ResponseExample>
  ```json theme={null}
  {
    "code": 200,
    "msg": "success",
    "data": {
      "embedding": [
        0.0234375,
        -0.015625,
        0.0078125,
        0.0390625,
        -0.0234375,
        "... (continues for vector length)"
      ]
    },
    "success": true,
    "failed": false
  }
  ```
</ResponseExample>

### Response Parameters

| Parameter      | Type           | Description                                                        |
| -------------- | -------------- | ------------------------------------------------------------------ |
| code           | string         | Response code indicating the result status (200 indicates success) |
| msg            | string         | Response message describing the operation result                   |
| data           | object         | Response data object containing the embedding                      |
| data.embedding | array\[number] | Vector embedding array (dimensionality depends on the model)       |
| success        | boolean        | Indicates whether the operation was successful                     |
| failed         | boolean        | Indicates whether the operation failed                             |

### Notes

* Image embeddings are returned synchronously in the response
* Embedding dimensions vary by model (typically 512-1024 dimensions)
* Supported image formats: JPEG, PNG, GIF, WebP, BMP, TIFF
* Maximum file size may vary by deployment
* Use the file upload method for one-time embedding generation
* Use the asset ID method when you've already uploaded the image via the `/upload` endpoint
* Embeddings can be used for image similarity search, classification, and clustering


## OpenAPI

````yaml POST /embeddings/image
openapi: 3.1.0
info:
  title: Embeddings API Reference
  description: REST APIs for generating vector embeddings from images, videos, and text
  version: v1.0.0
servers:
  - url: https://mavi-backend.memories.ai/serve/api/v2
security:
  - ApiKeyAuth: []
paths:
  /embeddings/image:
    post:
      summary: Generate Image Embedding
      operationId: image_embedding
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: Image file to upload
                model:
                  type: string
                  description: Embedding model name
                  example: multimodalembedding@001
                  enum:
                    - multimodalembedding@001
                    - mobileclip
              required:
                - model
          application/json:
            schema:
              type: object
              properties:
                asset_id:
                  type: string
                  description: Existing image asset ID
                  example: imc_657766047105290240_15
                model:
                  type: string
                  description: Embedding model name
                  example: multimodalembedding@001
                  enum:
                    - multimodalembedding@001
                    - mobileclip
              required:
                - asset_id
                - model
      responses:
        '200':
          description: Embedding generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: 200
                    description: Response code indicating the result status
                  msg:
                    type: string
                    example: success
                    description: Response message describing the operation result
                  data:
                    type: object
                    properties:
                      embedding:
                        type: array
                        items:
                          type: number
                        description: Vector embedding array
                        example:
                          - 0.0234375
                          - -0.015625
                          - 0.0078125
                          - 0.0390625
                    description: Response data object containing the embedding
                  success:
                    type: boolean
                    example: true
                    description: Indicates whether the operation was successful
                  failed:
                    type: boolean
                    example: false
                    description: Indicates whether the operation failed
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````