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

# Analyze an image

> Analyzes an image by URL or by inline image bytes. Returns a list of classifications for the image and, when OCR is enabled, the text extracted from the image along with its own text analysis.

Only **PNG**, **JPEG** and **WebP** images are accepted, and the image must not exceed **1 MiB** (1,048,576 bytes). Requests with an unsupported format or an oversized image are rejected with a `400 Bad Request`.

Before diving in, we recommend reading the [image taxonomy](/en/documentation/taxonomy/image-classifications) to understand the classifications returned by this endpoint.




## OpenAPI

````yaml /openapi/analyze.openapi.yaml post /analyze/v1/image
openapi: 3.1.0
info:
  title: Bodyguard Analyze API
  version: 1.0.0
servers:
  - url: https://api.bodyguard.ai
security:
  - ApiKeyAuth: []
tags:
  - name: Analyze
    description: Content analysis endpoints.
paths:
  /analyze/v1/image:
    post:
      tags:
        - Analyze
      summary: Analyze an image
      description: >
        Analyzes an image by URL or by inline image bytes. Returns a list of
        classifications for the image and, when OCR is enabled, the text
        extracted from the image along with its own text analysis.


        Only **PNG**, **JPEG** and **WebP** images are accepted, and the image
        must not exceed **1 MiB** (1,048,576 bytes). Requests with an
        unsupported format or an oversized image are rejected with a `400 Bad
        Request`.


        Before diving in, we recommend reading the [image
        taxonomy](/en/documentation/taxonomy/image-classifications) to
        understand the classifications returned by this endpoint.
      operationId: bodyguard.analyze.v1.AnalyzeImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeImageRequest'
            examples:
              byUrl:
                summary: Analyze an image by URL
                value:
                  channelId: __YOUR_CHANNEL_ID__
                  publishedAt: '2026-04-23T10:30:00.000Z'
                  imageUrl: https://cdn.example.com/uploads/photo.jpg
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeImageRequest'
            examples:
              byBytes:
                summary: Analyze a base64-encoded image
                value:
                  channelId: __YOUR_CHANNEL_ID__
                  imageData: '[file content goes there]'
      responses:
        '200':
          description: Analysis completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeImageResponse'
              examples:
                classified:
                  summary: Image classified as sexual content
                  value:
                    imageAnalysis:
                      classifications:
                        - PARTIAL_NUDITY
                      classificationMeta:
                        PARTIAL_NUDITY:
                          confidenceScore: 0.92
                      ocrAnalysis:
                        text: Text extracted from the image
                        textAnalysis:
                          type: HATEFUL
                          classifications:
                            - INSULT
                          severity: HIGH
                          directedAt: AUTHOR_OF_COMMENT
                          language: en
                          recommendedAction: REMOVE
                          censoredText: Einstein is an *******
                          classificationMeta:
                            INSULT:
                              severity: MEDIUM
components:
  schemas:
    bodyguard.analyze.v1.AnalyzeImageRequest:
      type: object
      required:
        - channelId
      properties:
        channelId:
          type: string
          description: >-
            Identifier of the [channel](/en/api-reference/concepts#channel) the
            image belongs to. Provided by Bodyguard.
        publishedAt:
          type: string
          format: date-time
          description: >-
            [Publication
            date](/en/api-reference/concepts#publication-date-publishedat) of
            the image.
        imageUrl:
          type: string
          format: uri
          description: >
            Public URL of the image to analyze. The image must be a PNG, JPEG or
            WebP file no larger than 1 MiB. Only one of `imageUrl` or
            `imageData` can be provided.


            When fetching the image, Bodyguard sends the user-agent
            `Bodyguard-Analyze/1.0 (+https://bodyguard.ai/bot)`. If you
            allowlist Bodyguard on a CDN or firewall, match on the stable
            `Bodyguard-Analyze` product token rather than the full string — the
            version number and bot URL may change over time. Image fetches are
            not sent from a fixed set of IP addresses, so the user-agent is the
            signal to allowlist against.
        imageData:
          type: string
          format: byte
          description: >-
            Base64-encoded image bytes. The image must be a PNG, JPEG or WebP
            file no larger than 1 MiB. Only one of `imageUrl` or `imageData` can
            be provided.
      oneOf:
        - required:
            - imageUrl
        - required:
            - imageData
    bodyguard.analyze.v1.AnalyzeImageResponse:
      type: object
      properties:
        imageAnalysis:
          $ref: '#/components/schemas/bodyguard.analyze.v1.ImageAnalysis'
    bodyguard.analyze.v1.ImageAnalysis:
      type: object
      description: Moderation result for an image.
      properties:
        classifications:
          type: array
          description: >-
            Classifications detected on the image itself. An empty array means
            the image was analysed successfully and Bodyguard did not detect any
            sensitive content — it can be treated as safe.
          items:
            type: string
        classificationMeta:
          type: object
          additionalProperties:
            $ref: >-
              #/components/schemas/bodyguard.analyze.v1.ImageAnalysis.ClassificationMeta
        ocrAnalysis:
          description: >-
            Text extracted from the image by OCR, together with a text analysis.
            `null` if OCR is disabled or no text was found in the image.
          oneOf:
            - $ref: >-
                #/components/schemas/bodyguard.analyze.v1.ImageAnalysis.OcrAnalysis
            - type: 'null'
    bodyguard.analyze.v1.ImageAnalysis.ClassificationMeta:
      type: object
      description: >-
        Additional metadata for each detected image classification. Keys match
        entries in `classifications`.
      properties:
        confidenceScore:
          type: number
          format: float
          minimum: 0
          maximum: 1
          description: >-
            Bodyguard's confidence that the classification applies to the image,
            between `0` and `1`. Higher means more confident. Relying on this
            score is discouraged: Bodyguard already filters out classifications
            whose confidence is too low, so the presence of a classification in
            the response is the signal you should use to decide whether to act
            on it.
    bodyguard.analyze.v1.ImageAnalysis.OcrAnalysis:
      type: object
      properties:
        text:
          type: string
          description: The text snippet extracted from the image.
        textAnalysis:
          $ref: '#/components/schemas/bodyguard.analyze.v1.TextAnalysis'
    bodyguard.analyze.v1.TextAnalysis:
      type: object
      description: Moderation result for a piece of text.
      properties:
        type:
          $ref: '#/components/schemas/bodyguard.std.v1.Type'
        classifications:
          type: array
          description: >-
            Fine-grained labels describing the content (e.g. `INSULT`, `SPAM`).
            See the [text
            taxonomy](/en/documentation/taxonomy/text-classifications) for the
            full list and descriptions of each classification.
          items:
            type: string
        severity:
          $ref: '#/components/schemas/bodyguard.std.v1.Severity'
        directedAt:
          $ref: '#/components/schemas/bodyguard.std.v1.DirectedAt'
        language:
          type: string
          description: Detected language as an ISO 639-1 code.
        recommendedAction:
          $ref: '#/components/schemas/bodyguard.std.v1.RecommendedAction'
        censoredText:
          type: string
          description: The original text with sensitive content censored with `*`.
        classificationMeta:
          type: object
          additionalProperties:
            $ref: >-
              #/components/schemas/bodyguard.analyze.v1.TextAnalysis.ClassificationMeta
    bodyguard.std.v1.Type:
      type: string
      description: >-
        The broad category of the analyzed content. For finer-grained detail,
        see `classifications`. See the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) for the full
        description of each value.
      enum:
        - NEUTRAL
        - HATEFUL
        - POSITIVE
        - NONE
        - HATE_SPEECH
        - CRITICISM
        - UNDESIRABLE
    bodyguard.std.v1.Severity:
      type: string
      description: >-
        Severity of the detected issue, if any. See the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) for the full
        description of each value.
      enum:
        - LOW
        - MEDIUM
        - HIGH
        - CRITICAL
        - NONE
    bodyguard.std.v1.DirectedAt:
      type: string
      description: >-
        Who or what the content is directed at. See the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) for the full
        description of each value.
      enum:
        - USER
        - USER_FAMILY
        - SINGLE_PERSON
        - GROUP
        - EVERYONE
        - AUTHOR_OF_COMMENT
        - HATERS
        - NONE
        - ENTITY
    bodyguard.std.v1.RecommendedAction:
      type: string
      description: The moderation action Bodyguard recommends you apply to this content.
      enum:
        - KEEP
        - REMOVE
        - WATCH
    bodyguard.analyze.v1.TextAnalysis.ClassificationMeta:
      type: object
      description: >
        Additional metadata for each detected classification.

        **Important:** Bodyguard cannot guarantee that this metadata will be
        present for every classification — for example, some non-toxic
        classifications may not have any."
      properties:
        severity:
          $ref: '#/components/schemas/bodyguard.std.v1.Severity'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        API key authentication. Provide your key in the `Authorization`
        header with the `ApiKey` scheme:
        ```
        Authorization: ApiKey <your-api-key>
        ```

````