# Examples

In this tutorial, we’ll show how to use Modal to schedule a daily report in a spreadsheet on Google Sheets that combines data from a PostgreSQL database with data from an external API. This example repo demonstrates how to use Modal and MongoDB together to build a full-stack application. Modal...

## Pages in this folder

| Page | Local file | Summary |
| --- | --- | --- |
| Write to Google Sheets from Postgres \| Modal Docs | [write-to-google-sheets-from-postgres-modal-docs.md](write-to-google-sheets-from-postgres-modal-docs.md) | In this tutorial, we’ll show how to use Modal to schedule a daily report in a spreadsheet on Google Sheets that combines data from a PostgreSQL database with data from an external API. |
| Using MongoDB Atlas Vector and GeoJSON Search with Modal \| Modal Docs | [using-mongodb-atlas-vector-and-geojson-search-with-modal-modal-docs.md](using-mongodb-atlas-vector-and-geojson-search-with-modal-modal-docs.md) | This example repo demonstrates how to use Modal and MongoDB together to build a full-stack application. |
| Use Modal Dicts and Queues together \| Modal Docs | [use-modal-dicts-and-queues-together-modal-docs.md](use-modal-dicts-and-queues-together-modal-docs.md) | Modal Dicts and Queues store and communicate objects in distributed applications on Modal. |
| Train an SLM from scratch with early-stopping grid search over hyperparameters \| Modal Docs | [train-an-slm-from-scratch-with-early-stopping-grid-search-over-hyperparameters-modal-docs.md](train-an-slm-from-scratch-with-early-stopping-grid-search-over-hyperparameters-modal-docs.md) | When you want a language model that performs well on your task, there are three options, ordered by the degree of customization: |
| Train a model to solve math problems using GRPO and verl \| Modal Docs | [train-a-model-to-solve-math-problems-using-grpo-and-verl-modal-docs.md](train-a-model-to-solve-math-problems-using-grpo-and-verl-modal-docs.md) | This example demonstrates how to train with GRPO on Modal using the verl framework. GRPO is a reinforcement learning algorithm introduced by DeepSeek, and was used to train DeepSeek R1. verl is a reinforcement learning training library that is an implementation of HybridFlow, an RLHF framework. |
| Train a model to solve coding problems using GRPO and TRL \| Modal Docs | [train-a-model-to-solve-coding-problems-using-grpo-and-trl-modal-docs.md](train-a-model-to-solve-coding-problems-using-grpo-and-trl-modal-docs.md) | This example demonstrates how to run GRPO on Modal using the TRL GRPO trainer GRPO is a reinforcement learning algorithm introduced by DeepSeek, and was used to train DeepSeek R1. TRL is a reinforcement learning training library by Huggingface. |
| Tracing and profiling GPU-accelerated PyTorch programs on Modal \| Modal Docs | [tracing-and-profiling-gpu-accelerated-pytorch-programs-on-modal-modal-docs.md](tracing-and-profiling-gpu-accelerated-pytorch-programs-on-modal-modal-docs.md) | GPUs are high-performance computing devices. For high-performance computing, tools for measuring and investigating performance are as critical as tools for testing and confirming correctness in typical software. |
| Text-to-video generation with Mochi \| Modal Docs | [text-to-video-generation-with-mochi-modal-docs.md](text-to-video-generation-with-mochi-modal-docs.md) | This example demonstrates how to run the Mochi 1 video generation model by Genmo on Modal. |
| Stream transcriptions with Kyutai STT \| Modal Docs | [stream-transcriptions-with-kyutai-stt-modal-docs.md](stream-transcriptions-with-kyutai-stt-modal-docs.md) | This example demonstrates the deployment of a streaming audio transcription service with Kyutai STT on Modal. |
| Snapshot GPU memory to speed up cold starts \| Modal Docs | [snapshot-gpu-memory-to-speed-up-cold-starts-modal-docs.md](snapshot-gpu-memory-to-speed-up-cold-starts-modal-docs.md) | This example demonstrates how to use GPU memory snapshots to speed up model loading. Note that GPU memory snapshotting is an experimental feature, so test carefully before using in production! You can read more about GPU memory snapshotting, and its caveats, here. |
| Set “fallback” GPUs \| Modal Docs | [set-fallback-gpus-modal-docs.md](set-fallback-gpus-modal-docs.md) | GPU availabilities on Modal can fluctuate, especially for tightly-constrained requests, like for eight co-located GPUs in a specific region. |
| Serverless TensorRT-LLM (LLaMA 3 8B) \| Modal Docs | [serverless-tensorrt-llm-llama-3-8b-modal-docs.md](serverless-tensorrt-llm-llama-3-8b-modal-docs.md) | In this example, we demonstrate how to use the TensorRT-LLM framework to serve Meta’s LLaMA 3 8B model at very high throughput. |
| Serverless Qwen 3-8B with SGLang and Modal Snapshots \| Modal Docs | [serverless-qwen-3-8b-with-sglang-and-modal-snapshots-modal-docs.md](serverless-qwen-3-8b-with-sglang-and-modal-snapshots-modal-docs.md) | In this example, we show how to serve SGLang on Modal with ~10x faster cold starts. |
| Serverless Ministral 3 with vLLM and Modal \| Modal Docs | [serverless-ministral-3-with-vllm-and-modal-modal-docs.md](serverless-ministral-3-with-vllm-and-modal-modal-docs.md) | In this example, we show how to serve Mistral’s Ministral 3 vision-language models on Modal. |
| Serverless Ministral 3 with vLLM and Modal \| Modal Docs | [serverless-ministral-3-with-vllm-and-modal-modal-docs-2.md](serverless-ministral-3-with-vllm-and-modal-modal-docs-2.md) | In this example, we show how to serve Mistral’s Ministral 3 vision-language models on Modal. |
| Serve very large language models (DeepSeek V3, Kimi-K2, GLM 4.7/5) \| Modal Docs | [serve-very-large-language-models-deepseek-v3-kimi-k2-glm-4-7-5-modal-docs.md](serve-very-large-language-models-deepseek-v3-kimi-k2-glm-4-7-5-modal-docs.md) | This example demonstrates the basic patterns for serving language models on Modal whose weights consume hundreds of gigabytes of storage. |
| Serve a receipt parsing web app \| Modal Docs | [serve-a-receipt-parsing-web-app-modal-docs.md](serve-a-receipt-parsing-web-app-modal-docs.md) | This tutorial shows you how to use Modal to deploy a fully serverless React + FastAPI application. |
| Serve a Discord Bot on Modal \| Modal Docs | [serve-a-discord-bot-on-modal-modal-docs.md](serve-a-discord-bot-on-modal-modal-docs.md) | In this example we will demonstrate how to use Modal to build and serve a Discord bot that uses slash commands. |
| Run TextEmbeddingsInference (TEI) on Modal \| Modal Docs | [run-textembeddingsinference-tei-on-modal-modal-docs.md](run-textembeddingsinference-tei-on-modal-modal-docs.md) | This example runs the Text Embedding Inference (TEI) toolkit on the Hacker News BigQuery public dataset. |
| Run Stable Diffusion 3.5 Large Turbo as a CLI, API, and web UI \| Modal Docs | [run-stable-diffusion-3-5-large-turbo-as-a-cli-api-and-web-ui-modal-docs.md](run-stable-diffusion-3-5-large-turbo-as-a-cli-api-and-web-ui-modal-docs.md) | This example shows how to run Stable Diffusion 3.5 Large Turbo on Modal to generate images from your local command line, via an API, and as a web UI. |
| Run OpenCV face detection on an image \| Modal Docs | [run-opencv-face-detection-on-an-image-modal-docs.md](run-opencv-face-detection-on-an-image-modal-docs.md) | This example shows how you can use OpenCV on Modal to detect faces in an image. We use the opencv-python package to load the image and the opencv library to detect faces. The function count_faces takes an image as input and returns the number of faces detected in the image. |
| Run OpenCode in a Modal Sandbox \| Modal Docs | [run-opencode-in-a-modal-sandbox-modal-docs.md](run-opencode-in-a-modal-sandbox-modal-docs.md) | This example demonstrates how to run OpenCode remotely and connect to it from your local terminal or browser. |
| Run OpenAI’s gpt-oss model with vLLM \| Modal Docs | [run-openai-s-gpt-oss-model-with-vllm-modal-docs.md](run-openai-s-gpt-oss-model-with-vllm-modal-docs.md) | gpt-oss is a reasoning model that comes in two flavors: gpt-oss-120B and gpt-oss-20B. They are both Mixture of Experts (MoE) models with a low number of active parameters, ensuring they combine good world knowledge and capabilities with fast inference. |
| Run OpenAI-compatible LLM inference with Gemma and vLLM \| Modal Docs | [run-openai-compatible-llm-inference-with-gemma-and-vllm-modal-docs.md](run-openai-compatible-llm-inference-with-gemma-and-vllm-modal-docs.md) | In this example, we show how to run a vLLM server in OpenAI-compatible mode on Modal. |
| Run OpenAI-compatible LLM inference with Gemma and vLLM \| Modal Docs | [run-openai-compatible-llm-inference-with-gemma-and-vllm-modal-docs-2.md](run-openai-compatible-llm-inference-with-gemma-and-vllm-modal-docs-2.md) | In this example, we show how to run a vLLM server in OpenAI-compatible mode on Modal. |
| Run long, resumable training jobs on Modal \| Modal Docs | [run-long-resumable-training-jobs-on-modal-modal-docs.md](run-long-resumable-training-jobs-on-modal-modal-docs.md) | Individual Modal Function calls have a maximum timeout of 24 hours. You can still run long training jobs on Modal by making them interruptible and resumable (aka reentrant). |
| Run LLM inference at maximum throughput \| Modal Docs | [run-llm-inference-at-maximum-throughput-modal-docs.md](run-llm-inference-at-maximum-throughput-modal-docs.md) | This example demonstrates some techniques for running LLM inference at the highest possible throughput on Modal. |
| Run Flux fast on H100s with torch.compile \| Modal Docs | [run-flux-fast-on-h100s-with-torch-compile-modal-docs.md](run-flux-fast-on-h100s-with-torch-compile-modal-docs.md) | Update: To speed up inference by another >2x, check out the additional optimization techniques we tried in this blog post! |
| Run Facebook’s Segment Anything Model 2 (SAM 2) on Modal \| Modal Docs | [run-facebook-s-segment-anything-model-2-sam-2-on-modal-modal-docs.md](run-facebook-s-segment-anything-model-2-sam-2-on-modal-modal-docs.md) | This example demonstrates how to deploy Facebook’s SAM 2 on Modal. SAM2 is a powerful, flexible image and video segmentation model that can be used for various computer vision tasks like object detection, instance segmentation, and even as a foundation for more complex computer vision applications. SAM2 extends the capabilities of the original SAM to include video segmentation. |
| Run cron jobs in the cloud to search Hacker News \| Modal Docs | [run-cron-jobs-in-the-cloud-to-search-hacker-news-modal-docs.md](run-cron-jobs-in-the-cloud-to-search-hacker-news-modal-docs.md) | In this example, we use Modal to deploy a cron job that periodically queries Hacker News for new posts matching a given search term, and posts the results to Slack. |
| Run Continuous Integration (CI) Tests on Modal \| Modal Docs | [run-continuous-integration-ci-tests-on-modal-modal-docs.md](run-continuous-integration-ci-tests-on-modal-modal-docs.md) | Run CI tests on Modal with GPU access. Execute pytest in the cloud as part of your GitHub Actions workflow. |
| Run Claude Code in a Modal Sandbox \| Modal Docs | [run-claude-code-in-a-modal-sandbox-modal-docs.md](run-claude-code-in-a-modal-sandbox-modal-docs.md) | This example demonstrates how to run Claude Code in a Modal Sandbox to analyze a GitHub repository. The Sandbox provides an isolated environment where the agent can safely execute code and examine files. |
| Run arbitrary code in a sandboxed environment \| Modal Docs | [run-arbitrary-code-in-a-sandboxed-environment-modal-docs.md](run-arbitrary-code-in-a-sandboxed-environment-modal-docs.md) | This example demonstrates how to run arbitrary code in multiple languages in a Modal Sandbox. |
| Run Anthropic’s computer use demo in a Modal Sandbox \| Modal Docs | [run-anthropic-s-computer-use-demo-in-a-modal-sandbox-modal-docs.md](run-anthropic-s-computer-use-demo-in-a-modal-sandbox-modal-docs.md) | This example demonstrates how to run Anthropic’s Computer Use demo in a Modal Sandbox. |
| Run and share Streamlit apps \| Modal Docs | [run-and-share-streamlit-apps-modal-docs.md](run-and-share-streamlit-apps-modal-docs.md) | This example shows you how to run a Streamlit app with modal serve, and then deploy it as a serverless web app. |
| Run a Jupyter notebook in a Modal Sandbox \| Modal Docs | [run-a-jupyter-notebook-in-a-modal-sandbox-modal-docs.md](run-a-jupyter-notebook-in-a-modal-sandbox-modal-docs.md) | This example demonstrates how to run a Jupyter notebook in a Modal Sandbox. |
| Run a job queue that turns documents into structured data with Datalab Marker \| Modal Docs | [run-a-job-queue-that-turns-documents-into-structured-data-with-datalab-marker-modal-docs.md](run-a-job-queue-that-turns-documents-into-structured-data-with-datalab-marker-modal-docs.md) | This tutorial shows you how to use Modal as an infinitely scalable job queue that can service async tasks from a web app. |
| Run a FastRTC app on Modal \| Modal Docs | [run-a-fastrtc-app-on-modal-modal-docs.md](run-a-fastrtc-app-on-modal-modal-docs.md) | FastRTC is a Python library for real-time communication on the web. This example demonstrates how to run a simple FastRTC app in the cloud on Modal. |
| Retrieval-augmented generation (RAG) for question-answering with LangChain \| Modal Docs | [retrieval-augmented-generation-rag-for-question-answering-with-langchain-modal-docs.md](retrieval-augmented-generation-rag-for-question-answering-with-langchain-modal-docs.md) | In this example we create a large-language-model (LLM) powered question answering Web Function and CLI. Only a single document is used as the knowledge-base of the application, the 2022 USA State of the Union address by President Joe Biden. However, this same application structure could be extended to do question-answering over all State of the Union speeches, or other large text corpuses. |
| Render a video with Blender on many GPUs or CPUs in parallel \| Modal Docs | [render-a-video-with-blender-on-many-gpus-or-cpus-in-parallel-modal-docs.md](render-a-video-with-blender-on-many-gpus-or-cpus-in-parallel-modal-docs.md) | This example shows how you can render an animated 3D scene using Blender’s Python interface. |
| Real-time object detection with WebRTC and YOLO \| Modal Docs | [real-time-object-detection-with-webrtc-and-yolo-modal-docs.md](real-time-object-detection-with-webrtc-and-yolo-modal-docs.md) | This example demonstrates how to architect a serverless real-time streaming application with Modal and WebRTC. The sample application detects objects in webcam video with YOLO. |
| QuiLLMan: Voice Chat with Moshi \| Modal Docs | [quillman-voice-chat-with-moshi-modal-docs.md](quillman-voice-chat-with-moshi-modal-docs.md) | QuiLLMan is a complete voice chat application built on Modal: you speak and the chatbot speaks back! |
| Publish interactive datasets with Datasette \| Modal Docs | [publish-interactive-datasets-with-datasette-modal-docs.md](publish-interactive-datasets-with-datasette-modal-docs.md) | Build and deploy an interactive movie database that automatically updates daily with the latest IMDb data. This example shows how to serve a Datasette application on Modal with millions of movie and TV show records. |
| Publish custom metrics with Prometheus Pushgateway \| Modal Docs | [publish-custom-metrics-with-prometheus-pushgateway-modal-docs.md](publish-custom-metrics-with-prometheus-pushgateway-modal-docs.md) | This example shows how to publish custom metrics to a Prometheus instance with Modal. Due to a Modal container’s ephemeral nature, it’s not a good fit for a traditional scraping-based Prometheus setup. Instead, we’ll use a Prometheus Pushgateway to collect and store metrics from our Modal container. We can run the Pushgateway in Modal as a separate process and have our application push metrics to it. |
| Play with the ControlNet demos \| Modal Docs | [play-with-the-controlnet-demos-modal-docs.md](play-with-the-controlnet-demos-modal-docs.md) | This example allows you to play with all 10 demonstration Gradio apps from the new and amazing ControlNet project. ControlNet provides a minimal interface allowing users to use images to constrain StableDiffusion’s generation process. With ControlNet, users can easily condition the StableDiffusion image generation with different spatial contexts including a depth maps, segmentation maps, scribble drawings, and keypoints! |
| MultiOn: Twitter News Agent \| Modal Docs | [multion-twitter-news-agent-modal-docs.md](multion-twitter-news-agent-modal-docs.md) | In this example, we use Modal to deploy a cron job that periodically checks for AI news everyday and tweets it on Twitter using the MultiOn Agent API. |
| Modal Vibe: A scalable AI coding platform \| Modal Docs | [modal-vibe-a-scalable-ai-coding-platform-modal-docs.md](modal-vibe-a-scalable-ai-coding-platform-modal-docs.md) | The Modal Vibe repo demonstrates how you can build a scalable AI coding platform on Modal. |
| Miscellaneous examples \| Modal Docs | [miscellaneous-examples-modal-docs.md](miscellaneous-examples-modal-docs.md) | Additional Modal examples including ControlNet, FastHTML, Mochi video, PyTorch profiling, and more. |
| Make music with ACE-Step 1.5 \| Modal Docs | [make-music-with-ace-step-1-5-modal-docs.md](make-music-with-ace-step-1-5-modal-docs.md) | In this example, we show you how you can run ACE Studio’s ACE-Step 1.5 music generation model on Modal. |
| Make music with ACE-Step 1.5 \| Modal Docs | [make-music-with-ace-step-1-5-modal-docs-2.md](make-music-with-ace-step-1-5-modal-docs-2.md) | In this example, we show you how you can run ACE Studio’s ACE-Step 1.5 music generation model on Modal. |
| Maintain a pool of warm Sandboxes that are healthy and ready to serve requests \| Modal Docs | [maintain-a-pool-of-warm-sandboxes-that-are-healthy-and-ready-to-serve-requests-modal-docs.md](maintain-a-pool-of-warm-sandboxes-that-are-healthy-and-ready-to-serve-requests-modal-docs.md) | This example demonstrates how to build a pool of “warm” Modal Sandboxes, and deploy a Modal Web Function that lets you claim a Sandbox from the pool, getting a URL to the server running in the Sandbox. |
| Low Latency, Serverless LFM2 with vLLM and Modal \| Modal Docs | [low-latency-serverless-lfm2-with-vllm-and-modal-modal-docs.md](low-latency-serverless-lfm2-with-vllm-and-modal-modal-docs.md) | In this example, we show how to serve Liquid AI’s LFM2 models with vLLM with low latency and fast cold starts on Modal. |
| Low latency Qwen 3.6 with SGLang and Modal \| Modal Docs | [low-latency-qwen-3-6-with-sglang-and-modal-modal-docs.md](low-latency-qwen-3-6-with-sglang-and-modal-modal-docs.md) | In this example, we show how to serve SGLang at low latency on Modal. |
| Low latency Nvidia Nemotron 3 with SGLang and Modal \| Modal Docs | [low-latency-nvidia-nemotron-3-with-sglang-and-modal-modal-docs.md](low-latency-nvidia-nemotron-3-with-sglang-and-modal-modal-docs.md) | In this example, we show how to serve Nvidia’s Nemotron models on Modal at low latency with SGLang. |
| LoRAs Galore: Create a LoRA Playground with Modal, Gradio, and S3 \| Modal Docs | [loras-galore-create-a-lora-playground-with-modal-gradio-and-s3-modal-docs.md](loras-galore-create-a-lora-playground-with-modal-gradio-and-s3-modal-docs.md) | This example shows how to mount an S3 bucket in a Modal app using CloudBucketMount. We will download a bunch of LoRA adapters from the HuggingFace Hub into our S3 bucket then read from that bucket, on the fly, when doing inference. |
| Installing the CUDA Toolkit on Modal \| Modal Docs | [installing-the-cuda-toolkit-on-modal-modal-docs.md](installing-the-cuda-toolkit-on-modal-modal-docs.md) | This code sample is intended to quickly show how different layers of the CUDA stack are used on Modal. For greater detail, see our guide to using CUDA on Modal. |
| High-throughput LLM inference with Tokasaurus (LLama 3.2 1B Instruct) \| Modal Docs | [high-throughput-llm-inference-with-tokasaurus-llama-3-2-1b-instruct-modal-docs.md](high-throughput-llm-inference-with-tokasaurus-llama-3-2-1b-instruct-modal-docs.md) | In this example, we demonstrate how to use Tokasaurus, an LLM inference framework designed for maximum throughput. |
| Hello, world! \| Modal Docs | [hello-world-modal-docs.md](hello-world-modal-docs.md) | This tutorial demonstrates some core features of Modal: |
| Hello world wide web! \| Modal Docs | [hello-world-wide-web-modal-docs.md](hello-world-wide-web-modal-docs.md) | Modal makes it easy to turn your Python functions into serverless web services: access them via a browser or call them from any client that speaks HTTP, all without having to worry about setting up servers or managing infrastructure. |
| Generate videos from prompts with Lightricks LTX-Video \| Modal Docs | [generate-videos-from-prompts-with-lightricks-ltx-video-modal-docs.md](generate-videos-from-prompts-with-lightricks-ltx-video-modal-docs.md) | This example demonstrates how to run the LTX-Video video generation model by Lightricks on Modal. |
| Fold proteins with Chai-1 \| Modal Docs | [fold-proteins-with-chai-1-modal-docs.md](fold-proteins-with-chai-1-modal-docs.md) | In biology, function follows form quite literally: the physical shapes of proteins dictate their behavior. Measuring those shapes directly is difficult and first-principles physical simulation prohibitively expensive. |
| Fold proteins with Boltz-2 \| Modal Docs | [fold-proteins-with-boltz-2-modal-docs.md](fold-proteins-with-boltz-2-modal-docs.md) | Boltz-2 is an open source molecular structure prediction model. In contrast to previous models like Boltz-1, Chai-1, and AlphaFold-3, it not only predicts protein structures but also the binding affinities between proteins and ligands. It was created by the MIT Jameel Clinic. For details, see their technical report. |
| Fine-tune Whisper to Improve Transcription on Domain-Specific Vocab \| Modal Docs | [fine-tune-whisper-to-improve-transcription-on-domain-specific-vocab-modal-docs.md](fine-tune-whisper-to-improve-transcription-on-domain-specific-vocab-modal-docs.md) | This example demonstrates how to fine-tune an ASR model (whisper-tiny.en) and deploy it for inference using Modal. |
| Fine-tune open source YOLO models for object detection \| Modal Docs | [fine-tune-open-source-yolo-models-for-object-detection-modal-docs.md](fine-tune-open-source-yolo-models-for-object-detection-modal-docs.md) | Example by @Erik-Dunteman and @AnirudhRahul. |
| Fine-tune Flux on your pet using LoRA \| Modal Docs | [fine-tune-flux-on-your-pet-using-lora-modal-docs.md](fine-tune-flux-on-your-pet-using-lora-modal-docs.md) | This example finetunes the Flux.1-dev model on images of a pet (by default, a puppy named Qwerty) using a technique called textual inversion from the “Dreambooth” paper. Effectively, it teaches a general image generation model a new “proper noun”, allowing for the personalized generation of art and photos. We supplement textual inversion with low-rank adaptation (LoRA) for increased efficiency during training. |
| Featured examples \| Modal Docs | [featured-examples-modal-docs.md](featured-examples-modal-docs.md) | How to run LLMs, Stable Diffusion, data-intensive processing, computer vision, audio transcription, and other tasks on Modal. |
| Fast Whisper inference using dynamic batching \| Modal Docs | [fast-whisper-inference-using-dynamic-batching-modal-docs.md](fast-whisper-inference-using-dynamic-batching-modal-docs.md) | In this example, we demonstrate how to run dynamically batched inference for OpenAI’s speech recognition model, Whisper, on Modal. Batching multiple audio samples together or batching chunks of a single audio sample can help to achieve a 2.8x increase in inference throughput on an A10G! |
| Embed 30 million Amazon reviews at 575k tokens per second with Qwen2-7B \| Modal Docs | [embed-30-million-amazon-reviews-at-575k-tokens-per-second-with-qwen2-7b-modal-docs.md](embed-30-million-amazon-reviews-at-575k-tokens-per-second-with-qwen2-7b-modal-docs.md) | This example demonstrates how to create embeddings for a large text dataset. This is often necessary to enable semantic search, translation, and other language processing tasks. Modal makes it easy to deploy large, capable embedding models and handles all of the scaling to process very large datasets in parallel on many cloud GPUs. |
| Efficient LLM Finetuning with Unsloth \| Modal Docs | [efficient-llm-finetuning-with-unsloth-modal-docs.md](efficient-llm-finetuning-with-unsloth-modal-docs.md) | Training large language models is an incredibly compute-hungry process. Open-source LLMs often require many GBs (or in extreme cases, one TB!) of VRAM just to fit in memory. Finetuning models requires even more memory; a common estimate for naive finetuning puts the VRAM requirements at roughly 4.2x the original model size: 1x for model weights + 1x for gradients + 2x for optimizer state + 20% for activations. Parameter efficient methods like LoRA can improve matters significantly, since this estimate now applies to just the LoRA modules’ weights, rather than the entire model’s. Further gains can be made with quantization of each of the components mentioned above, but doing so requires quantization-aware training, which can be tricky to combine with methods like LoRA. |
| Edit images with Flux Kontext \| Modal Docs | [edit-images-with-flux-kontext-modal-docs.md](edit-images-with-flux-kontext-modal-docs.md) | In this example, we run the Flux Kontext model in image-to-image mode: the model takes in a prompt and an image and edits the image to better match the prompt. |
| DoppelBot: Fine-tune an LLM to replace your CEO \| Modal Docs | [doppelbot-fine-tune-an-llm-to-replace-your-ceo-modal-docs.md](doppelbot-fine-tune-an-llm-to-replace-your-ceo-modal-docs.md) | Fine-tune Llama on Slack messages to create a bot that mimics your writing style. Full serverless training and inference. |
| DoppelBot: Fine-tune an LLM to replace your CEO \| Modal Docs | [doppelbot-fine-tune-an-llm-to-replace-your-ceo-modal-docs-2.md](doppelbot-fine-tune-an-llm-to-replace-your-ceo-modal-docs-2.md) | Fine-tune Llama on Slack messages to create a bot that mimics your writing style. Full serverless training and inference. |
| Design protein binders at scale with ESMFold2 and ESMC \| Modal Docs | [design-protein-binders-at-scale-with-esmfold2-and-esmc-modal-docs.md](design-protein-binders-at-scale-with-esmfold2-and-esmc-modal-docs.md) | Protein folding was a landmark breakthrough in computational biology. But for many applications, we don’t just want to predict the structures of existing proteins — we want to design new proteins that can modulate biology. |
| Deploy a remote, stateless MCP server on Modal with FastMCP \| Modal Docs | [deploy-a-remote-stateless-mcp-server-on-modal-with-fastmcp-modal-docs.md](deploy-a-remote-stateless-mcp-server-on-modal-with-fastmcp-modal-docs.md) | This example demonstrates how to deploy a simple MCP server on Modal. |
| Deploy a personalized music video generation service on Modal \| Modal Docs | [deploy-a-personalized-music-video-generation-service-on-modal-modal-docs.md](deploy-a-personalized-music-video-generation-service-on-modal-modal-docs.md) | Generate personalized music videos with AI on Modal. Deploy your own music video generator using serverless GPU infrastructure. |
| Deploy a FastHTML app with Modal \| Modal Docs | [deploy-a-fasthtml-app-with-modal-modal-docs.md](deploy-a-fasthtml-app-with-modal-modal-docs.md) | This example shows how you can deploy a FastHTML app with Modal. FastHTML is a Python library built on top of HTMX which allows you to create entire web applications using only Python. |
| Deploy 100,000 multiplayer checkboxes on Modal with FastHTML \| Modal Docs | [deploy-100-000-multiplayer-checkboxes-on-modal-with-fasthtml-modal-docs.md](deploy-100-000-multiplayer-checkboxes-on-modal-with-fasthtml-modal-docs.md) | This example shows how you can deploy a multiplayer checkbox game with FastHTML on Modal. |
| Create a Chatterbox TTS API on Modal \| Modal Docs | [create-a-chatterbox-tts-api-on-modal-modal-docs.md](create-a-chatterbox-tts-api-on-modal-modal-docs.md) | This example demonstrates how to deploy a text-to-speech (TTS) API using the open source model Chatterbox Turbo on Modal. |
| Claude Slack GIF Creator \| Modal Docs | [claude-slack-gif-creator-modal-docs.md](claude-slack-gif-creator-modal-docs.md) | This repo shows how to build a bot powered by Claude that creates custom Slackmoji-ready GIFs. |
| Chat with PDF: RAG with ColQwen2 \| Modal Docs | [chat-with-pdf-rag-with-colqwen2-modal-docs.md](chat-with-pdf-rag-with-colqwen2-modal-docs.md) | In this example, we demonstrate how to use the the ColQwen2 model to build a simple “Chat with PDF” retrieval-augmented generation (RAG) app. The ColQwen2 model is based on ColPali but uses the Qwen2-VL-2B-Instruct vision-language model. ColPali is in turn based on the late-interaction embedding approach pioneered in ColBERT. |
| Build your own data warehouse with DuckDB, DBT, and Modal \| Modal Docs | [build-your-own-data-warehouse-with-duckdb-dbt-and-modal-modal-docs.md](build-your-own-data-warehouse-with-duckdb-dbt-and-modal-modal-docs.md) | This example contains a minimal but capable data warehouse. It’s comprised of the following: |
| Build a stateful, sandboxed code interpreter \| Modal Docs | [build-a-stateful-sandboxed-code-interpreter-modal-docs.md](build-a-stateful-sandboxed-code-interpreter-modal-docs.md) | This example demonstrates how to build a stateful code interpreter using a Modal Sandbox. |
| Build a protein folding dashboard with ESM3, Molstar, and Gradio \| Modal Docs | [build-a-protein-folding-dashboard-with-esm3-molstar-and-gradio-modal-docs.md](build-a-protein-folding-dashboard-with-esm3-molstar-and-gradio-modal-docs.md) | There are perhaps a quadrillion distinct proteins on the planet Earth, each one a marvel of nanotechnology discovered by painstaking evolution. We know the amino acid sequence of nearly a billion but we only know the three-dimensional structure of a few hundred thousand, gathered by slow, difficult observational methods like X-ray crystallography. Built upon this data are machine learning models like EvolutionaryScale’s ESM3 that can predict the structure of any sequence in seconds. |
| Build a coding agent with Modal Sandboxes and LangGraph \| Modal Docs | [build-a-coding-agent-with-modal-sandboxes-and-langgraph-modal-docs.md](build-a-coding-agent-with-modal-sandboxes-and-langgraph-modal-docs.md) | This example demonstrates how to build an LLM coding “agent” that can generate and execute Python code, using documentation from the web to inform its approach. |
| Animate images with Lightricks LTX-Video via CLI, API, and web UI \| Modal Docs | [animate-images-with-lightricks-ltx-video-via-cli-api-and-web-ui-modal-docs.md](animate-images-with-lightricks-ltx-video-via-cli-api-and-web-ui-modal-docs.md) | This example shows how to run LTX-Video on Modal to generate videos from your local command line, via an API, and in a web UI. |
| Analyze NYC yellow taxi data with DuckDB on Parquet files from S3 \| Modal Docs | [analyze-nyc-yellow-taxi-data-with-duckdb-on-parquet-files-from-s3-modal-docs.md](analyze-nyc-yellow-taxi-data-with-duckdb-on-parquet-files-from-s3-modal-docs.md) | This example shows how to use Modal for a classic data science task: loading table-structured data into cloud stores, analyzing it, and plotting the results. |
| Algolia docsearch crawler \| Modal Docs | [algolia-docsearch-crawler-modal-docs.md](algolia-docsearch-crawler-modal-docs.md) | This tutorial shows you how to use Modal to run the Algolia docsearch crawler to index your website and make it searchable. This is not just example code - we run the same code in production to power search on this page (Ctrl+K to try it out!). |
| Add Modal Apps to Tailscale \| Modal Docs | [add-modal-apps-to-tailscale-modal-docs.md](add-modal-apps-to-tailscale-modal-docs.md) | This example demonstrates how to integrate Modal with Tailscale (https://tailscale.com). It outlines the steps to configure Modal containers so that they join the Tailscale network. |
| A simple web scraper \| Modal Docs | [a-simple-web-scraper-modal-docs.md](a-simple-web-scraper-modal-docs.md) | In this guide we’ll introduce you to Modal by writing a simple web scraper. We’ll explain the foundations of a Modal application step by step. |
