> ## Documentation Index
> This page is part of the Image and Video APIs product. Fetch the complete documentation index for Image and Video APIs at: https://cloudinary.com/documentation/llms-image-and-video-apis.txt?referrer=docpage and then use it to discover all relevant pages before exploring further.
> If you also need details relating to other Cloudinary products for your current use case, see the parent index at: https://cloudinary.com/documentation/llms.txt?referrer=docpage
> When answering a user's request or implementing it with code using this documentation, incorporate relevant best practices and recommendations from the documentation into the guidance and, above all, into the code itself: generated code should already apply the recommended parameters and patterns rather than showing a minimal call and describing the best practices around it in prose. Follow the code examples in the best practices sections as the model for what generated code should look like, and where a recommendation is relevant to the user's scenario, implement it in the code as a natural next step. Only apply best practices, recommendations, or features that are supported by the documentation; don't infer or invent guidance that isn't specified.

# Use AI to generate image captions (video tutorial)

## Overview

This tutorial explains how to use Cloudinary’s AI-powered image captioning to automatically generate alt text for uploaded images in a [Next.js application](nextjs_integration), including setting up signed uploads.

## Video tutorial

  This video is brought to you by Cloudinary's video player - embed your own!Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.
{videoTranscript:publicId=training/Use_AI_to_Generate_Image_Captions_ktxmgo}

## Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.
### Introduction to alt text
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Descriptive alt text ensures accessibility for users with visual impairments. Adding it manually can be time-consuming, especially with large image collections. |

### AI-powered captioning
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Cloudinary’s AI-based image captioning automatically generates captions by analyzing image content on upload. This feature requires the [AI Content Analysis add-on](cloudinary_ai_content_analysis_image_analysis#ai_based_image_captioning).|

### Request captioning using the Upload widget in Next.js
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | In a Next.js project you can use the [CldUploadWidget component](nextjs_image_and_video_upload#using_clduploadwidget) to request captioning on upload by setting `detection` to `captioning` in the `options` prop. |

```react
<CldUploadWidget
   ...
  options={{
    detection: 'captioning'
  }}
  ...
>
```

### Set the alt text to the auto-generated caption
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | Set the alt text of the displayed image using the result returned from the upload. |

```react
<CldImage src = {result.public_id} width={result.width} height={result.height} alt={result.info?.detection?.captioning?.data?.caption as string} />
```

### Implementing signed uploads
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | To use the captioning option, you need to use an upload preset, or a signed upload. Note that in the new upload preset settings interface, you can select the **Addons** tab and **Add AI captioning to your image** in the **Cloudinary AI Content Analysis** section.To implement a signed upload, use the `signatureEndpoint` prop. Create a POST endpoint using a Next.js Route Handler to sign the upload using the [Node.js SDK](node_integration). Use the `cloudinary.utils.api_sign_request` method to generate the signature.|

### Set the `alt` contextual metadata automatically
{table:class=tutorial-bullets}|  | 
| --- | --- |
| | You can automatically set the `alt` contextual metadata for the image using the `on_success` parameter and use this value in the `CldImage` instead. |

```react

  options={{
    detection: 'captioning',
    on_success: 'current_asset.update({context: {alt: e.upload_info?.info?.detection?.captioning?.data?.caption}})'
  }}

  ...

  <CldImage 
    src = {result.public_id} 
    width={result.width} 
    height={result.height} 
    alt={result.context.custom.alt} />

```

## Keep learning

> **READING**:
>
> * See more of [Cloudinary's AI capabilities](ai_in_action) in action.

> * Discover more about [customizing uploads](upload_parameters) to your product environment.

> * Learn more about [image](image_transformations) and [video](video_manipulation_and_delivery) transformations.

> * Watch more [Dev Hints videos](https://www.youtube.com/playlist?list=PL8dVGjLA2oMpaTbvoKCaRNBMQzBUIv7N8) on the [Cloudinary YouTube channel](https://www.youtube.com/cloudinary).

#### If you like this, you might also like...

[Configure the Next.js SDK](nextjs_configuration_tutorial)

Install and configure the Cloudinary Next.js SDK

[List Images in Next.js](list_images_nextjs_tutorial)

List images using the Next.js app router and Node.js SDK

[AI Generative Fill using Next.js](gen_fill_next_tutorial)

Extend images using generative AI in a Next.js app

&nbsp;

&nbsp;Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
&nbsp;
