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

# Download an XAI map

> Download the **Attention Map** or the **Attention Graph** produced by the [XAI – eXplainable AI](/classification/classify-image#xai-explainable-ai) scope for a model, for an image submitted with `with_xai=true` or for a frame of a video submitted with `with_xai=true` (use the `identifier` of the frame in `results.images`).

The maps produced depend on the model: the `explanations` of the per-model results list the `type` and `method` of every map available for the model, also when the AI-powered explanations were not requested. The heatmap of the Smart Full Analysis is not an XAI map: download it with the [heatmap endpoint](./get-classification-heatmap).

**Note:** This endpoint also has an alias available at `/api/classification_image/xai/{identifier}`.



## OpenAPI

````yaml get /api/classification/xai/{identifier}
openapi: 3.0.0
info:
  title: identifAI API
  version: 1.0.0
  description: >-
    API for integrating identifAI's image and video classification
    capabilities.<br><details><summary>**How to obtain your API
    Key**</summary>To obtain your API key, follow these simple steps:  
    <ol><li><p>**Create a user profile and log in to the platform**</p>If you
    don't have an account yet, visit our platform and create a user profile.
    Once you've completed registration and verified your email, log in with your
    credentials.</li><li><p>**Access the user menu**</p>After logging in, click
    on your name or the user icon in the top-right corner of the
    screen.</li><li><p>**Select the API Key option**</p>In the dropdown menu
    that appears, select the "API Key" option. From there, you can view or
    generate your API key.</li></ol>Now you are ready to use your API key in our
    API!</details><details><summary>**How to use the API**</summary>To use the
    API, first make a **POST** request to start the classification. Then, use
    the provided ***identifier*** from the **POST** request to retrieve the
    results.

    <details>

    <summary>**1. Image Classification**</summary>
      * To classify an image, you need to make a **POST** request to `/api/classification` with the required parameters (for details on the parameters, refer to the *"Classification"* section below).
      * In the response, you will receive the ***identifier*** of the classified image.
      * Use the provided ***identifier*** to retrieve the classification results by making a **GET** request to `/api/classification/{identifier}` (for details on how to structure this request, see the *"Classification"* section below).
      * The response will contain the classification results for the image in JSON format.<br>In the response, you will find a ***results*** array, which includes the classification results for each model used, and a ***verdicts*** array, which contains the results for each heuristic applied.<br>If the classification is not yet complete, continue sending the **GET** request until the result is available.</details><details><summary>**2. Video Classification**</summary>
        * To classify a video, you need to make a **POST** request to `/api/classification_video` with the required parameters (for details on the parameters, refer to the *"Classification"* section below).
        * In the response, you will receive the ***identifier*** of the classified video.
        * Use the provided ***identifier*** to retrieve the classification results by making a **GET** request to `/api/classification_video/{identifier}` (for details on how to structure this request, see the *"Classification"* section below).
        * The response will provide the classification results for the video in JSON format. For video classification, the video is divided into *frames*.<br> In the response, you will find a ***results*** array that includes the classification outcomes for each model applied to each analyzed frame, and a ***verdicts*** array containing the results for each heuristic used.<br> If the classification is not complete, continue sending the **GET** request until the final results are returned.</details><details><summary>**3. All Classifications**</summary>The `/api/classifications` endpoint will return all the image classifications made by a user. This will list the results of all past image classification requests.</details><details><summary>**4. User Management**</summary>  The **POST** `/api/user` endpoint allows you to create a user, while the **DELETE** `/api/user` endpoint is used to delete a user (For the structure of the requests, see more in the user section below).</details></details>
servers:
  - url: https://backend.identifai.net
security: []
tags:
  - name: Classification
    description: Classification routes
  - name: Infrastructure
    description: Infrastructure routes
  - name: User
    description: User actions
  - name: Partner
    description: Partner actions
paths:
  /api/classification/xai/{identifier}:
    get:
      tags:
        - Classification
      summary: Download an XAI map
      description: >-
        Download the **Attention Map** or the **Attention Graph** produced by
        the [XAI – eXplainable
        AI](/classification/classify-image#xai-explainable-ai) scope for a
        model, for an image submitted with `with_xai=true` or for a frame of a
        video submitted with `with_xai=true` (use the `identifier` of the frame
        in `results.images`).


        The maps produced depend on the model: the `explanations` of the
        per-model results list the `type` and `method` of every map available
        for the model, also when the AI-powered explanations were not requested.
        The heatmap of the Smart Full Analysis is not an XAI map: download it
        with the [heatmap endpoint](./get-classification-heatmap).


        **Note:** This endpoint also has an alias available at
        `/api/classification_image/xai/{identifier}`.
      parameters:
        - name: identifier
          in: path
          required: true
          schema:
            type: string
          description: The identifier of the image, or of the video frame.
        - name: model
          in: query
          required: true
          schema:
            type: string
          description: >-
            The name of the model that produced the map, as reported in the
            `model` field of the per-model results (e.g. `Revelio`).
        - name: method
          in: query
          required: true
          schema:
            type: string
            enum:
              - legrad
              - transformer_attribution
              - attention_rollout
          description: The XAI method used to compute the map.
        - name: type
          in: query
          required: false
          schema:
            type: string
            enum:
              - attention_map
              - attention_graph
            default: attention_map
          description: >-
            The map to download: `attention_map` (overlaid on the original
            content) or `attention_graph` (trend and peaks of the attention of
            the model).
      responses:
        '200':
          description: The XAI map, as an image.
          content:
            image/png:
              schema:
                type: string
                format: binary
        '400':
          description: Missing `model` or `method`, or invalid `type`.
          content:
            application/json:
              examples:
                missing_parameters:
                  summary: Missing parameters
                  value:
                    error: 'Missing required parameters: model, method'
                invalid_type:
                  summary: Invalid type
                  value:
                    error: >-
                      Invalid type parameter. Allowed values: attention_map,
                      attention_graph
        '401':
          description: Invalid or missing API key.
          content:
            application/json:
              example:
                error: Unauthorized
        '403':
          description: >-
            The image or frame does not exist or you are not authorized to
            access it.
          content:
            application/json:
              example:
                error: Unauthorized
        '404':
          description: >-
            No map of the requested model, method and type is available for the
            image or frame.
          content:
            application/json:
              example:
                error: Not found
        '429':
          description: Too many requests.
          content:
            application/json:
              example:
                error: Too Many Attempts.
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: X-Api-Key
      in: header
      description: Your API key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.