Modal

Examples catalog (116)

Indexed from modal-examples. Use the slug to pin an example on an event.

SlugTitleThemesGPURun
generatorsRun a generator function on Modalmodal run 01_getting_started/generators.py
hello_worldHello, world!getting_started, batchmodal run 01_getting_started/hello_world.py
install_cudaInstalling the CUDA Toolkit on ModalwebT4modal run 02_building_containers/install_cuda.py
install_flash_attnInstall Flash Attention on ModalvisionL40Smodal run 02_building_containers/install_flash_attn.py
basic_grid_searchHyperparameter searchrag, vision, getting_startedmodal run 03_scaling_out/basic_grid_search.py
cls_with_optionsOverride Modal resource options (GPU, scaling) at runtime with `Cls.with_options`T4modal run 03_scaling_out/cls_with_options.py
dynamic_batchingDynamic batching for ASCII and character conversionbatchmodal run 03_scaling_out/dynamic_batching.py
db_to_sheetWrite to Google Sheets from Postgreswebmodal deploy 04_secrets/db_to_sheet.py
hackernews_alertsRun cron jobs in the cloud to search Hacker Newsrag, visionmodal run 05_scheduling/hackernews_alerts.py
schedule_simpleScheduling remote jobsgetting_startedmodal run 05_scheduling/schedule_simple.py
whisperx_transcribeWhisperX transcription with word-level timestampsspeech, visionH100modal run 06_gpu_and_ml/audio-to-text/whisperx_transcribe.py
esmfold2_binder_designDesign protein binders at scale with ESMFold2 and ESMCH100modal run 06_gpu_and_ml/binder-design/esmfold2_binder_design.py
blender_videoRender a video with Blender on many GPUs or CPUs in parallelvision, batchL40Smodal run 06_gpu_and_ml/blender/blender_video.py
controlnet_gradio_demosPlay with the ControlNet demosvision, webA10Gmodal run 06_gpu_and_ml/controlnet/controlnet_gradio_demos.py
amazon_embeddingsEmbed 30 million Amazon reviews at 575k tokens per second with Qwen2-7Brag, batch, llmL40Smodal run 06_gpu_and_ml/embeddings/amazon_embeddings.py
image_embeddings_infinityModal Cookbook: Recipe for Inference Throughput Maximizationrag, batch, visiongpumodal run 06_gpu_and_ml/embeddings/image_embeddings_infinity.py
liquidai_embeddings_serverServe Liquid AI ColBERT embeddings with llama.cpp and Modal Serversrag, batch, llmmodal run 06_gpu_and_ml/embeddings/liquidai_embeddings_server.py
gpu_fallbacksSet "fallback" GPUssubprocessmodal run 06_gpu_and_ml/gpu_fallbacks.py
gpu_snapshotSnapshot GPU memory to speed up cold startsa10modal deploy 06_gpu_and_ml/gpu_snapshot.py
hp_sweep_gptTrain an SLM from scratch with early-stopping grid search over hyperparametersllm, vision, ragA10Gmodal run 06_gpu_and_ml/hyperparameter-sweep/hp_sweep_gpt.py
image_to_videoAnimate images with Lightricks LTX-Video via CLI, API, and web UIvision, webH100modal run 06_gpu_and_ml/image-to-video/image_to_video.py
potus_speech_qandaRetrieval-augmented generation (RAG) for question-answering with LangChainrag, llm, speechmodal run 06_gpu_and_ml/langchains/potus_speech_qanda.py
chat_with_pdf_visionChat with PDF: RAG with ColQwen2llm, rag, visionA100-80GBmodal run 06_gpu_and_ml/llm-serving/chat_with_pdf_vision.py
deepseek_v4Serve DeepSeek V4 Pro on Modal with SGLangllm, visionfmodal run 06_gpu_and_ml/llm-serving/deepseek_v4.py
deepseek_v4_flashDeploy DeepSeek-V4-Flash with SGLang and Modalllmfmodal run 06_gpu_and_ml/llm-serving/deepseek_v4_flash.py
gpt_oss_inferenceRun OpenAI's gpt-oss model with vLLMllmfmodal run 06_gpu_and_ml/llm-serving/gpt_oss_inference.py
inkling_smallServe Inkling-Small on Modal with SGLangllm, visionfmodal run 06_gpu_and_ml/llm-serving/inkling_small.py
lfm_snapshotLow Latency, Serverless LFM2 with vLLM and Modalllm, ragGPUmodal run 06_gpu_and_ml/llm-serving/lfm_snapshot.py
ministral3_inferenceServerless Ministral 3 with vLLM and Modalllm, visionfmodal run 06_gpu_and_ml/llm-serving/ministral3_inference.py
nemotron_inferenceLow latency Nvidia Nemotron 3 with SGLang and ModalllmGPUmodal run 06_gpu_and_ml/llm-serving/nemotron_inference.py
sglang_low_latencyLow latency Qwen 3.6 with SGLang and ModalllmGPUmodal run 06_gpu_and_ml/llm-serving/sglang_low_latency.py
sglang_snapshotServerless Qwen 3-8B with SGLang and Modal SnapshotsllmGPUmodal run 06_gpu_and_ml/llm-serving/sglang_snapshot.py
sglang_vlmServe the Qwen 3.6 Vision-Language Model with SGLangllm, vision, web, getting_startedGPUmodal run 06_gpu_and_ml/llm-serving/sglang_vlm.py
stepfun_inferenceRun StepFun models with SGLangllmGPUmodal run 06_gpu_and_ml/llm-serving/stepfun_inference.py
trtllm_latencyServe an interactive language model app with low-latency TensorRT-LLM (LLaMA 3 8B)llmGPUmodal run 06_gpu_and_ml/llm-serving/trtllm_latency.py
trtllm_throughputServerless TensorRT-LLM (LLaMA 3 8B)llmGPUmodal run 06_gpu_and_ml/llm-serving/trtllm_throughput.py
very_large_modelsServe very large language models (DeepSeek V3, Kimi-K2, GLM 4.7/5)llm, ragfmodal run 06_gpu_and_ml/llm-serving/very_large_models.py
vllm_inferenceRun OpenAI-compatible LLM inference with Gemma and vLLMllm, webfmodal run 06_gpu_and_ml/llm-serving/vllm_inference.py
vllm_low_latencyLow latency Qwen 3 8B with vLLM and Modalllm, getting_startedGPUmodal run 06_gpu_and_ml/llm-serving/vllm_low_latency.py
vllm_throughputRun LLM inference at maximum throughputllm, getting_startedGPUmodal run 06_gpu_and_ml/llm-serving/vllm_throughput.py
long-trainingRun long, resumable training jobs on Modaltraininga10gmodal run 06_gpu_and_ml/long-training.py
fine_tune_asrFine-tune Whisper to Improve Transcription on Domain-Specific Vocabspeech, trainingH100modal run 06_gpu_and_ml/openai_whisper/fine_tune_asr.py
paint_flowersPainting flowers with codetraining, llm, visionmodal run 06_gpu_and_ml/paint_flowers/paint_flowers.py
boltz_predictFold proteins with Boltz-2H100modal run 06_gpu_and_ml/protein-folding/boltz_predict.py
chai1Fold proteins with Chai-1getting_startedH100modal run 06_gpu_and_ml/protein-folding/chai1.py
esm3Build a protein folding dashboard with ESM3, Molstar, and Gradiovision, webA10Gmodal run 06_gpu_and_ml/protein-folding/esm3.py
esmfold2Fold proteins and biomolecular complexes with ESMFold2H100modal run 06_gpu_and_ml/protein-folding/esmfold2.py
isaac_labTrain a robot in a simulated environment with Isaac Labtrainingfmodal run 06_gpu_and_ml/reinforcement-learning/isaac_lab.py
mjlab_motion_imitationTeach a humanoid to imitate motion with mjlabtrainingA10modal run 06_gpu_and_ml/reinforcement-learning/mjlab_motion_imitation.py
segment_anythingRun Facebook's Segment Anything Model 2 (SAM 2) on ModalvisionA100modal run 06_gpu_and_ml/sam/segment_anything.py
batched_whisperFast Whisper inference using dynamic batchingspeech, batcha10gmodal run 06_gpu_and_ml/speech-to-text/batched_whisper.py
parakeet_multitalkerParakeet Multi-talker Speech-to-Textspeechmodal run 06_gpu_and_ml/speech-to-text/parakeet_multitalker.py
sortformer2_1_speaker_diarizationStreaming Speaker Diarization with Sortformer2.1speechL4modal run 06_gpu_and_ml/speech-to-text/sortformer2_1_speaker_diarization.py
streaming_kyutai_sttStream transcriptions with Kyutai STTspeecha10gmodal deploy 06_gpu_and_ml/speech-to-text/streaming_kyutai_stt.py
streaming_parakeetStreaming audio transcription using Parakeetspeecha10gmodal run 06_gpu_and_ml/speech-to-text/streaming_parakeet.py
fluxRun Flux fast on H100s with `torch.compile`visionH100modal run 06_gpu_and_ml/stable_diffusion/flux.py
image_to_imageEdit images with Flux Kontextvision, getting_startedB200modal run 06_gpu_and_ml/stable_diffusion/image_to_image.py
text_to_imageRun Stable Diffusion 3.5 Large Turbo as a CLI, API, and web UIvision, web, batchH100modal run 06_gpu_and_ml/stable_diffusion/text_to_image.py
swe_gymTrain coding agentsagents, sandboxes, training, webmodal run 06_gpu_and_ml/swe_gym/swe_gym.py
tensorflow_tutorialTensorFlow tutorialvisionT4modal run 06_gpu_and_ml/tensorflow/tensorflow_tutorial.py
chatterbox_ttsCreate a Chatterbox TTS API on Modalspeech, llm, weba10gmodal run 06_gpu_and_ml/text-to-audio/chatterbox_tts.py
generate_musicMake music with ACE-Step 1.5llm, visionl40smodal run 06_gpu_and_ml/text-to-audio/generate_music.py
ltxGenerate videos from prompts with Lightricks LTX-VideovisionH100modal run 06_gpu_and_ml/text-to-video/ltx.py
ltx2_two_stageHigh-quality text-to-video with LTX-2vision, trainingH200modal run 06_gpu_and_ml/text-to-video/ltx2_two_stage.py
mochiText-to-video generation with MochivisionH100modal run 06_gpu_and_ml/text-to-video/mochi.py
torch_profilingTracing and profiling GPU-accelerated PyTorch programs on Modalmodal run 06_gpu_and_ml/torch_profiling.py
text_to_worldGenerate 3D worlds from text with LTX-2.3 and InSpatio-Worldvision, trainingH200modal run 06_gpu_and_ml/world-models/text_to_world.py
finetune_yoloFine-tune open source YOLO models for object detectionvision, training, batchTRAINmodal run 06_gpu_and_ml/yolo/finetune_yolo.py
badgesServe a dynamic SVG badgevision, getting_startedmodal run 07_web/badges.py
basic_webHello world wide web!getting_startedh100modal run 07_web/basic_web.py
count_facesRun OpenCV face detection on an imagevisionmodal run 07_web/count_faces.py
fastapi_appDeploy FastAPI app with Modalwebmodal run 07_web/fastapi_app.py
fastrtc_flip_webcamRun a FastRTC app on Modalmodal deploy 07_web/fastrtc_flip_webcam.py
flask_appDeploy Flask app with Modalwebmodal run 07_web/flask_app.py
flask_streamingDeploy Flask app with streaming results with Modalmodal run 07_web/flask_streaming.py
serverDeploy HTTP Servers with ultra low latency on Modalllmmodal run 07_web/server.py
server_affinityAffinity routing for Modal Serversllm, getting_startedmodal run 07_web/server_affinity.py
sessioned_chatroomBuild a sessioned chat roomllmmodal run 07_web/sessioned_chatroom.py
streamingDeploy a FastAPI app with streaming responseswebmodal run 07_web/streaming.py
webrtc_yoloReal-time object detection with WebRTC and YOLOweb, visionA100-40GBmodal run 07_web/webrtc/webrtc_yolo.py
generators_asyncRun async generator function on Modalmodal run 08_advanced/generators_async.py
hello_world_asyncAsync functionsgetting_startedmodal run 08_advanced/hello_world_async.py
parallel_executionParallel execution on Modal with `spawn` and `gather`batchmodal run 08_advanced/parallel_execution.py
poll_delayed_resultPolling for a delayed result on Modalmodal run 08_advanced/poll_delayed_result.py
dicts_and_queuesUse Modal Dicts and Queues togethermodal run 09_job_queues/dicts_and_queues.py
doc_ocr_jobsRun a job queue that turns documents into structured data with Datalab Markervisionl40smodal run 09_job_queues/doc_ocr_jobs.py
doc_ocr_webappServe a receipt parsing web appweb, visionmodal run 09_job_queues/doc_ocr_webapp.py
pipeline_orchestrationOrchestrate a multi-step pipeline with Modal Functionsmodal deploy 09_job_queues/pipeline_orchestration.py
web_job_queue_wrapperCreate a web wrapper for job queue, submission, polling, & resultsllm, vision, web, getting_startedmodal run 09_job_queues/web_job_queue_wrapper.py
algolia_indexerAlgolia docsearch crawlerragmodal deploy 10_integrations/algolia_indexer.py
cron_datasettePublish interactive datasets with Datasettebatchmodal deploy 10_integrations/cron_datasette.py
dbt_duckdbBuild your own data warehouse with DuckDB, DBT, and Modalragmodal deploy 10_integrations/dbt/dbt_duckdb.py
mcp_server_statelessDeploy a remote, stateless MCP server on Modal with FastMCPagentsmodal run 10_integrations/mcp_server_stateless.py
multion_news_agentMultiOn: Twitter News Agentagents, web, visionmodal run 10_integrations/multion_news_agent.py
pushgatewayPublish custom metrics with Prometheus Pushgatewaywebmodal deploy 10_integrations/pushgateway.py
s3_bucket_mountAnalyze NYC yellow taxi data with DuckDB on Parquet files from S3modal run 10_integrations/s3_bucket_mount.py
serve_streamlitRun and share Streamlit appswebmodal deploy 10_integrations/streamlit/serve_streamlit.py
modal_tailscaleAdd Modal Apps to Tailscalemodal run 10_integrations/tailscale/modal_tailscale.py
webscraperA simple web scrapermodal deploy 10_integrations/webscraper.py
webscraper_oldWeb Scraping on Modalwebmodal run 10_integrations/webscraper_old.py
agentBuild a coding agent with Modal Sandboxes and LangGraphagents, llm, sandboxesT4modal run 13_sandboxes/codelangchain/agent.py
langserveDeploy LangChain and LangGraph applications with LangServeagents, web, sandboxes, llmmodal run 13_sandboxes/codelangchain/langserve.py
computer_use_vncWatch a Browser Use agent drive Chromium over VNCagents, llm, sandboxes, webmodal run 13_sandboxes/cua/computer_use_vnc.py
harbor_evalsRun massively parallel evals on Modal Sandboxessandboxes, batch, llm, agentsmodal run 13_sandboxes/harbor_evals.py
jupyter_sandboxRun a Jupyter notebook in a Modal Sandboxsandboxes, visionNonemodal run 13_sandboxes/jupyter_sandbox.py
safe_code_executionRun arbitrary code in a sandboxed environmentsandboxes, visionmodal run 13_sandboxes/safe_code_execution.py
sandbox_agentRun Claude Code in a Modal Sandboxsandboxes, agents, vision, getting_startedmodal run 13_sandboxes/sandbox_agent.py
sandbox_poolMaintain a pool of warm Sandboxes that are healthy and ready to serve requestssandboxesmodal run 13_sandboxes/sandbox_pool.py
sandbox_secret_injectionInject secrets into Sandbox HTTPS requests with an Outbound Policysandboxes, web, agentsmodal run 13_sandboxes/sandbox_secret_injection.py
sidecar_agentSeparate an agent from its execution environment with Sidecarsagents, sandboxesmodal run 13_sandboxes/sidecar_agent.py
sidecar_redisTest a web app with Redis in a Sidecarsandboxes, visionmodal run 13_sandboxes/sidecar_redis.py
sidecar_secrets_injectionInject Secrets into a Sandbox with a proxy Sidecarsandboxes, webmodal run 13_sandboxes/sidecar_secrets_injection.py
sidecar_traffic_routingFilter Sandbox HTTPS traffic with a proxy Sidecarsandboxes, webmodal run 13_sandboxes/sidecar_traffic_routing.py
simple_code_interpreterBuild a stateful, sandboxed code interpretersandboxesmodal run 13_sandboxes/simple_code_interpreter.py
miles_grpoMake LLMs better at mathtraining, llm, clusterfmodal run 14_clusters/miles_grpo.py
simple_torch_clusterSimple PyTorch clustercluster, getting_started, trainingGPUmodal run 14_clusters/simple_torch_cluster.py