---
title: "Flask Alt Text Generator"
description: "A flask API that generates a description for any image."
url: "https://vercel.com/templates/python/flask-alt-text-generator"
links:
  repository: "https://github.com/Nutlope/alt-text-generator"
  demo: "https://python-alt-text-generator.vercel.app/"
  deploy: "https://vercel.com/new/clone?demo-title=Flask+Alt+Text+Generator&demo-description=A+flask+API+that+generates+a+description+for+any+image.&demo-url=https%3A%2F%2Fpython-alt-text-generator.vercel.app%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F1CD8pDeFbTyw94gz7uqct2%2Fc7ad5bf1ae23b5aa29908bf77b7c66eb%2Fogimage.png&project-name=Flask+Alt+Text+Generator&repository-name=flask-alt-text-generator&repository-url=https%3A%2F%2Fgithub.com%2FNutlope%2Falt-text-generator&from=templates&skippable-integrations=1&env=REPLICATE_API_TOKEN"
---

# Flask Alt Text Generator

A flask API that generates a description for any image.

# Alt Image Generator

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/nutlope/alt-text-generator&env=REPLICATE_API_KEY&project-name=alt-tag-generator&repo-name=alt-tag-generator)

This Flask API will generate a description for any image using AI. If you're looking for the TypeScript version, [click here](https://github.com/vercel/examples/tree/main/solutions/alt-tag-generator).

![Alt Image Generator](https://github.com/Nutlope/alt-text-generator/blob/main/ogimage.png?raw=true)

## How it works

This project uses an ML modal from Salesforce called [BLIP](https://github.com/salesforce/BLIP) on [Replicate](https://replicate.com/) to generate relevant alt text for images. You can feed the Flask API endpoint an image as a query param and it will return a one sentence description of that image.

## Running Locally

After cloning the repo, go to [Replicate](https://replicate.com/) to make an account and put your API key in `.env`.

Then, run the following in the command line and your application will be available at `http://localhost:3000`

```bash
npm i -g vercel
vercel dev
```

To use the API route, go to the link below in your browser or run a curl command in your terminal to get a sample result. Feel free to replace the dub.sh link with a link to any image.

```bash
curl http://localhost:3000/generate?imageUrl=https://dub.sh/confpic
```

## Related Templates

### [Alt Text Generator](https://vercel.com/templates/next.js/ai-alt-text-generator)

Generate descriptions for your images using AI.

### [Python Hello World](https://vercel.com/templates/python/python-hello-world)

Use Python on Vercel with Serverless Functions using the Python Runtime.

### [Flask Hello World](https://vercel.com/templates/python/flask-hello-world)

Use Flask 3 on Vercel with Serverless Functions using the Python Runtime.

---

## Additional documentation

The [Vercel Knowledge Base](https://vercel.com/kb) contains guides and answers to common questions about Vercel, including deployment, framework configuration, domains, caching, and troubleshooting.
