---
title: "AI SDK with Flask"
description: "Use Flask and AI SDK on Vercel with Serverless Functions using the Python Runtime."
url: "https://vercel.com/templates/python/ai-sdk-with-flask"
links:
  repository: "https://github.com/vercel-labs/ai-sdk-flask"
  demo: "https://ai-sdk-preview-flask.vercel.app/api/generate?prompt=%22why%20is%20the%20sky%20blue?%22"
  deploy: "https://vercel.com/new/clone?demo-title=AI+SDK+with+Flask&demo-description=Use+Flask+and+AI+SDK+on+Vercel+with+Serverless+Functions+using+the+Python+Runtime.&demo-url=https%3A%2F%2Fai-sdk-preview-flask.vercel.app%2Fapi%2Fgenerate%3Fprompt%3D%2522why%2520is%2520the%2520sky%2520blue%3F%2522&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F2NEAZ5bvvNxFkZC33B0Jkw%2F4785501923516ea84706d16f5c9b8998%2Fpython.png&project-name=AI+SDK+with+Flask&repository-name=ai-sdk-with-flask&repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-sdk-flask&from=templates&skippable-integrations=1&root-directories=List+of+directory+paths+for+the+directories+to+clone+into+projects&project-names=Comma+separated+list+of+project+names%2Cto+match+the+root-directories"
---

# AI SDK with Flask

Use Flask and AI SDK on Vercel with Serverless Functions using the Python Runtime.

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-sdk-flask&project-name=ai-sdk-flask&repository-name=ai-sdk-flask&demo-title=AI%20SDK%20and%20Flask%20API&demo-description=Use%20Flask%20API%20and%20AI%20SDK%20on%20Vercel%20with%20Serverless%20Functions%20using%20the%20Python%20Runtime.&demo-url=https%3A%2F%2Fai-sdk-preview-flask.vercel.app&demo-image=https%3A%2F%2Fassets.vercel.com%2Fimage%2Fupload%2Fv1669994600%2Frandom%2Fpython.png)

# Flask + Vercel

This example shows how to use Flask and AI SDK on Vercel with Serverless Functions using the [Python Runtime](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/python).

## Demo

https://ai-sdk-preview-flask.vercel.app/api/generate?prompt="hey!"

## How it Works

This example uses the Web Server Gateway Interface (WSGI) with Flask to handle requests on Vercel with Serverless Functions.

## Running Locally

```bash
npm i -g vercel
python -m venv .venv
source .venv/bin/activate
uv sync  # or alternatively pip install flask gunicorn
gunicorn main:app
```

Your Flask application is now available at `http://localhost:3000`.

---

## 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.
