[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EEG4X0ZXW16KCN7KGT4GHT":3,"skill-same:01M7EEG4X0ZXW16KCN7KGT4GHT":110},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":39,"commitSha":40,"skillDirectory":41,"forksCount":42,"repositoryHtmlUrl":43,"repositoryHomepageUrl":6,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":45,"updatedAt":46,"install":47,"resources":59},"01M7EEG4X0ZXW16KCN7KGT4GHT","modal",null,"Modal is a serverless cloud platform for running Python on demand, including on-demand GPUs. Use when deploying or serving AI\u002FML models, running GPU-accelerated workloads (training, fine-tuning, inference), serving web endpoints, scheduling batch jobs, or scaling Python code to cloud containers with the Modal SDK.","sanjeevafk\u002Fagent-skills","sanjeevafk","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F230678117?v=4","01M7C540EFY46ETG1NNWKS5X3Q","Sanjeev","01M7C540F366J5C1D587BMKH9Q",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: modal\ndescription: Modal is a serverless cloud platform for running Python on demand, including on-demand GPUs. Use when deploying or serving AI\u002FML models, running GPU-accelerated workloads (training, fine-tuning, inference), serving web endpoints, scheduling batch jobs, or scaling Python code to cloud containers with the Modal SDK.\nlicense: Apache-2.0\nmetadata:\n  version: \"1.2\"\n  skill-author: K-Dense Inc.\n  openclaw:\n    envVars:\n    - name: MODAL_TOKEN_ID\n      required: true\n      description: Modal token id.\n    - name: MODAL_TOKEN_SECRET\n      required: true\n      description: Modal token secret.\n    - name: DATABASE_URL\n      required: false\n      description: Optional database URL for examples.\n---\n\n# Modal\n\n## Overview\n\nModal is a cloud platform for running Python code serverlessly, with a focus on AI\u002FML workloads. Key capabilities:\n- **GPU compute** on demand (T4, L4, A10, L40S, A100, H100, H200, B200)\n- **Serverless functions** with autoscaling from zero to thousands of containers\n- **Custom container images** built entirely in Python code\n- **Persistent storage** via Volumes for model weights and datasets\n- **Web endpoints** for serving models and APIs\n- **Scheduled jobs** via cron or fixed intervals\n- **Sub-second cold starts** for low-latency inference\n\nEverything in Modal is defined as code — no YAML, no Dockerfiles required (though both are supported).\n\n## When to Use This Skill\n\nUse this skill when:\n- Deploy or serve AI\u002FML models in the cloud\n- Run GPU-accelerated computations (training, inference, fine-tuning)\n- Create serverless web APIs or endpoints\n- Scale batch processing jobs in parallel\n- Schedule recurring tasks (data pipelines, retraining, scraping)\n- Need persistent cloud storage for model weights or datasets\n- Want to run code in custom container environments\n- Build job queues or async task processing systems\n\n## Installation and Authentication\n\n### Install\n\n```bash\nuv pip install modal\n```\n\nThe Modal Python SDK supports Python 3.10–3.14. This skill targets the stable `modal>=1.0` API (current release: 1.4.x).\n\n### Authenticate\n\nPrefer existing credentials before creating new ones. Only the two Modal-specific\nvariables below are relevant — do not read, load, or expose any other environment\nvariables or `.env` file contents:\n\n1. Check whether `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` are already set in the current environment.\n2. If not, look up only those two keys in a local `.env` file (ignore all other entries) and load them if appropriate for the workflow.\n3. Only fall back to interactive `modal setup` or generating fresh tokens if neither source already provides those two values.\n\n```bash\nmodal setup\n```\n\nThis opens a browser for authentication. For CI\u002FCD or headless environments, use environment variables:\n\n```bash\nexport MODAL_TOKEN_ID=\u003Cyour-token-id>\nexport MODAL_TOKEN_SECRET=\u003Cyour-token-secret>\n```\n\nIf tokens are not already available in the environment or `.env`, generate them at https:\u002F\u002Fmodal.com\u002Fsettings\n\nModal offers a free tier with $30\u002Fmonth in credits.\n\n**Reference**: See `references\u002Fgetting-started.md` for detailed setup and first app walkthrough.\n\n## Core Concepts\n\n### App and Functions\n\nA Modal `App` groups related functions. Functions decorated with `@app.function()` run remotely in the cloud:\n\n```python\nimport modal\n\napp = modal.App(\"my-app\")\n\n@app.function()\ndef square(x):\n    return x ** 2\n\n@app.local_entrypoint()\ndef main():\n    # .remote() runs in the cloud\n    print(square.remote(42))\n```\n\nRun with `modal run script.py`. Deploy with `modal deploy script.py`.\n\n**Reference**: See `references\u002Ffunctions.md` for lifecycle hooks, classes, `.map()`, `.spawn()`, and more.\n\n### Container Images\n\nModal builds container images from Python code. The recommended package installer is `uv`:\n\n```python\nimage = (\n    modal.Image.debian_slim(python_version=\"3.11\")\n    .uv_pip_install(\"torch==2.12.0\", \"transformers==5.9.0\", \"accelerate==1.13.0\")\n    .apt_install(\"git\")\n)\n\n@app.function(image=image)\ndef inference(prompt):\n    from transformers import pipeline\n    pipe = pipeline(\"text-generation\", model=\"meta-llama\u002FLlama-3-8B\")\n    return pipe(prompt)\n```\n\nKey image methods:\n- `.uv_pip_install()` — Install Python packages with uv (recommended)\n- `.pip_install()` — Install with pip (fallback)\n- `.apt_install()` — Install system packages\n- `.run_commands()` — Run shell commands during build\n- `.run_function()` — Run Python during build (e.g., download model weights)\n- `.add_local_python_source()` — Add local modules\n- `.env()` — Set environment variables\n\n**Reference**: See `references\u002Fimages.md` for Dockerfiles, micromamba, caching, GPU build steps.\n\n### GPU Compute\n\nRequest GPUs via the `gpu` parameter:\n\n```python\n@app.function(gpu=\"H100\")\ndef train_model():\n    import torch\n    device = torch.device(\"cuda\")\n    # GPU training code here\n\n# Multiple GPUs\n@app.function(gpu=\"H100:4\")\ndef distributed_training():\n    ...\n\n# GPU fallback chain\n@app.function(gpu=[\"H100\", \"A100-80GB\", \"A100-40GB\"])\ndef flexible_inference():\n    ...\n```\n\nAvailable GPUs: T4, L4, A10, L40S, A100-40GB, A100-80GB, RTX-PRO-6000, H100, H200, B200, B200+\n\n- GPUs are always specified as **strings** (e.g. `gpu=\"H100\"`, `gpu=\"H100:4\"`). The old `modal.gpu.*` objects are deprecated as of v0.73.31.\n- Up to 8 GPUs per container (except A10: up to 4)\n- L40S is recommended for inference (cost\u002Fperformance balance, 48 GB VRAM)\n- H100\u002FA100 can be auto-upgraded to H200\u002FA100-80GB at no extra cost\n- Use `gpu=\"H100!\"` to prevent auto-upgrade\n\n**Reference**: See `references\u002Fgpu.md` for GPU selection guidance and multi-GPU training.\n\n### Volumes (Persistent Storage)\n\nVolumes provide distributed, persistent file storage:\n\n```python\nvol = modal.Volume.from_name(\"model-weights\", create_if_missing=True)\n\n@app.function(volumes={\"\u002Fdata\": vol})\ndef save_model():\n    # Write to the mounted path\n    with open(\"\u002Fdata\u002Fmodel.pt\", \"wb\") as f:\n        torch.save(model.state_dict(), f)\n\n@app.function(volumes={\"\u002Fdata\": vol})\ndef load_model():\n    model.load_state_dict(torch.load(\"\u002Fdata\u002Fmodel.pt\"))\n```\n\n- Optimized for write-once, read-many workloads (model weights, datasets)\n- CLI access: `modal volume ls`, `modal volume put`, `modal volume get`\n- Background auto-commits every few seconds\n- Mount read-only or limit to a subdirectory with `vol.with_mount_options(read_only=True, sub_path=\"subset\")`\n\n**Reference**: See `references\u002Fvolumes.md` for v2 volumes, concurrent writes, and best practices.\n\n### Secrets\n\nSecurely pass credentials to functions:\n\n```python\n@app.function(secrets=[modal.Secret.from_name(\"my-api-keys\")])\ndef call_api():\n    import os\n    api_key = os.environ[\"API_KEY\"]\n    # Use the key\n```\n\nCreate secrets via CLI: `modal secret create my-api-keys API_KEY=sk-xxx`\n\nOr from a `.env` file: `modal.Secret.from_dotenv()`\n\n**Reference**: See `references\u002Fsecrets.md` for dashboard setup, multiple secrets, and templates.\n\n### Web Endpoints\n\nServe models and APIs as web endpoints:\n\n```python\n@app.function()\n@modal.fastapi_endpoint()\ndef predict(text: str):\n    return {\"result\": model.predict(text)}\n```\n\n- `modal serve script.py` — Development with hot reload and temporary URL\n- `modal deploy script.py` — Production deployment with permanent URL\n- Supports FastAPI, ASGI (Starlette, FastHTML), WSGI (Flask, Django), WebSockets\n- Request bodies up to 4 GiB, unlimited response size\n\n**Reference**: See `references\u002Fweb-endpoints.md` for ASGI\u002FWSGI apps, streaming, auth, and WebSockets.\n\n### Scheduled Jobs\n\nRun functions on a schedule:\n\n```python\n@app.function(schedule=modal.Cron(\"0 9 * * *\"))  # Daily at 9 AM UTC\ndef daily_pipeline():\n    # ETL, retraining, scraping, etc.\n    ...\n\n@app.function(schedule=modal.Period(hours=6))\ndef periodic_check():\n    ...\n```\n\nDeploy with `modal deploy script.py` to activate the schedule.\n\n- `modal.Cron(\"...\")` — Standard cron syntax, stable across deploys\n- `modal.Period(hours=N)` — Fixed interval, resets on redeploy\n- Monitor runs in the Modal dashboard\n\n**Reference**: See `references\u002Fscheduled-jobs.md` for cron syntax and management.\n\n### Scaling and Concurrency\n\nModal autoscales containers automatically. Configure limits:\n\n```python\n@app.function(\n    max_containers=100,    # Upper limit\n    min_containers=2,      # Keep warm for low latency\n    buffer_containers=5,   # Reserve capacity\n    scaledown_window=300,  # Idle seconds before shutdown\n)\ndef process(data):\n    ...\n```\n\nProcess inputs in parallel with `.map()`:\n\n```python\nresults = list(process.map([item1, item2, item3, ...]))\n```\n\nEnable concurrent request handling per container with `@modal.concurrent`. Set\n`target_inputs` (the autoscaler's per-container target) below `max_inputs` (the hard\ncap) to keep headroom while scaling up:\n\n```python\n@app.function()\n@modal.concurrent(max_inputs=10, target_inputs=8)\nasync def handle_request(req):\n    ...\n```\n\nReconfigure a deployed Function or Cls at invocation time without redeploying using\n`Function.with_options()` \u002F `Function.with_concurrency()` \u002F `Function.with_batching()`\n(and `Cls.with_options()`):\n\n```python\nModel = modal.Cls.from_name(\"my-app\", \"Model\")\nfast = Model.with_options(gpu=\"H200\", max_containers=20)\nfast().generate.remote(prompt)\n```\n\n**Reference**: See `references\u002Fscaling.md` for `.map()`, `.starmap()`, `.spawn()`, and limits.\n\n### Resource Configuration\n\n```python\n@app.function(\n    cpu=4.0,              # Physical cores (not vCPUs)\n    memory=16384,         # MiB\n    ephemeral_disk=51200, # MiB (up to 3 TiB)\n    timeout=3600,         # Seconds\n)\ndef heavy_computation():\n    ...\n```\n\nDefaults: 0.125 CPU cores, 128 MiB memory. Billed on max(request, usage).\n\n**Reference**: See `references\u002Fresources.md` for limits and billing details.\n\n## Classes with Lifecycle Hooks\n\nFor stateful workloads (e.g., loading a model once and serving many requests):\n\n```python\n@app.cls(gpu=\"L40S\", image=image)\nclass Predictor:\n    @modal.enter()\n    def load_model(self):\n        self.model = load_heavy_model()  # Runs once on container start\n\n    @modal.method()\n    def predict(self, text: str):\n        return self.model(text)\n\n    @modal.exit()\n    def cleanup(self):\n        ...  # Runs on container shutdown\n```\n\nCall with: `Predictor().predict.remote(\"hello\")`\n\n## Sandboxes\n\nFor running untrusted or dynamically generated code (for example, AI-agent output or a code interpreter), use a `modal.Sandbox` — an isolated container you create and control programmatically rather than a decorated Function:\n\n```python\napp = modal.App.lookup(\"sandbox-demo\", create_if_missing=True)\n\n# Isolated container; restrict egress for untrusted workloads\nsb = modal.Sandbox.create(\n    app=app,\n    image=modal.Image.debian_slim(),\n    outbound_cidr_allowlist=[\"10.0.0.0\u002F8\"],\n)\n\n# Stream files in\u002Fout via the filesystem API (beta)\nsb.filesystem.write_text(\"print(2 ** 10)\\n\", \"\u002Ftmp\u002Fjob.py\")\ncontents = sb.filesystem.read_text(\"\u002Ftmp\u002Fjob.py\")\n\nsb.terminate()\n```\n\n- Run commands inside the sandbox with its `exec` method (e.g. run `python \u002Ftmp\u002Fjob.py`) and read stdout from the returned process handle — see `references\u002Fapi_reference.md`\n- Restrict connectivity with `outbound_cidr_allowlist=[...]` \u002F `inbound_cidr_allowlist=[...]`\n- Snapshot the filesystem with `sb.snapshot_filesystem()` to reuse as a base image\n- Ideal for code interpreters, agent tool execution, and per-user isolation\n\n## Common Workflow Patterns\n\n### GPU Model Inference Service\n\n```python\nimport modal\n\napp = modal.App(\"llm-service\")\n\nimage = (\n    modal.Image.debian_slim(python_version=\"3.11\")\n    .uv_pip_install(\"vllm\")\n)\n\n@app.cls(gpu=\"H100\", image=image, min_containers=1)\nclass LLMService:\n    @modal.enter()\n    def load(self):\n        from vllm import LLM\n        self.llm = LLM(model=\"meta-llama\u002FLlama-3-70B\")\n\n    @modal.method()\n    @modal.fastapi_endpoint(method=\"POST\")\n    def generate(self, prompt: str, max_tokens: int = 256):\n        outputs = self.llm.generate([prompt], max_tokens=max_tokens)\n        return {\"text\": outputs[0].outputs[0].text}\n```\n\n### Batch Processing Pipeline\n\n```python\napp = modal.App(\"batch-pipeline\")\nvol = modal.Volume.from_name(\"pipeline-data\", create_if_missing=True)\n\n@app.function(volumes={\"\u002Fdata\": vol}, cpu=4.0, memory=8192)\ndef process_chunk(chunk_id: int):\n    import pandas as pd\n    df = pd.read_parquet(f\"\u002Fdata\u002Finput\u002Fchunk_{chunk_id}.parquet\")\n    result = heavy_transform(df)\n    result.to_parquet(f\"\u002Fdata\u002Foutput\u002Fchunk_{chunk_id}.parquet\")\n    return len(result)\n\n@app.local_entrypoint()\ndef main():\n    chunk_ids = list(range(100))\n    results = list(process_chunk.map(chunk_ids))\n    print(f\"Processed {sum(results)} total rows\")\n```\n\n### Scheduled Data Pipeline\n\n```python\napp = modal.App(\"etl-pipeline\")\n\n@app.function(\n    schedule=modal.Cron(\"0 *\u002F6 * * *\"),  # Every 6 hours\n    secrets=[modal.Secret.from_name(\"db-credentials\")],\n)\ndef etl_job():\n    import os\n    db_url = os.environ[\"DATABASE_URL\"]\n    # Extract, transform, load\n    ...\n```\n\n## CLI Reference\n\n| Command | Description |\n|---------|-------------|\n| `modal setup` | Authenticate with Modal |\n| `modal run script.py` | Run a script's local entrypoint |\n| `modal serve script.py` | Dev server with hot reload |\n| `modal deploy script.py` | Deploy to production |\n| `modal volume ls \u003Cname>` | List files in a volume |\n| `modal volume put \u003Cname> \u003Cfile>` | Upload file to volume |\n| `modal volume get \u003Cname> \u003Cfile>` | Download file from volume |\n| `modal secret create \u003Cname> K=V` | Create a secret |\n| `modal secret list` | List secrets |\n| `modal app list` | List deployed apps |\n| `modal app stop \u003Cname>` | Stop a deployed app |\n\n## Security Notes\n\n- **Credentials:** Only `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` are needed to authenticate. Do not read, log, or forward any other environment variables or `.env` entries.\n- **Subprocess \u002F custom servers:** Some patterns here (multi-GPU training launchers, `@modal.web_server` apps) call `subprocess.run`\u002F`subprocess.Popen` or shell commands during builds. Keep argument lists fixed and hardcoded. Never construct subprocess or shell arguments from unsanitized user input — pass untrusted values as data (files, env vars, stdin), not as command arguments.\n- **Untrusted code:** Run user- or model-generated code inside a `modal.Sandbox` (see above), not a regular Function, and restrict network access with CIDR allowlists.\n\n## Reference Files\n\nDetailed documentation for each topic:\n\n- `references\u002Fgetting-started.md` — Installation, authentication, first app\n- `references\u002Ffunctions.md` — Functions, classes, lifecycle hooks, remote execution\n- `references\u002Fimages.md` — Container images, package installation, caching\n- `references\u002Fgpu.md` — GPU types, selection, multi-GPU, training\n- `references\u002Fvolumes.md` — Persistent storage, file management, v2 volumes\n- `references\u002Fsecrets.md` — Credentials, environment variables, dotenv\n- `references\u002Fweb-endpoints.md` — FastAPI, ASGI\u002FWSGI, streaming, auth, WebSockets\n- `references\u002Fscheduled-jobs.md` — Cron, periodic schedules, management\n- `references\u002Fscaling.md` — Autoscaling, concurrency, .map(), limits\n- `references\u002Fresources.md` — CPU, memory, disk, timeout configuration\n- `references\u002Fexamples.md` — Common use cases and patterns\n- `references\u002Fapi_reference.md` — Key API classes and methods\n\nRead these files when detailed information is needed beyond this overview.\n","# Modal\n\n## Overview\n\nModal is a cloud platform for running Python code serverlessly, with a focus on AI\u002FML workloads. Key capabilities:\n- **GPU compute** on demand (T4, L4, A10, L40S, A100, H100, H200, B200)\n- **Serverless functions** with autoscaling from zero to thousands of containers\n- **Custom container images** built entirely in Python code\n- **Persistent storage** via Volumes for model weights and datasets\n- **Web endpoints** for serving models and APIs\n- **Scheduled jobs** via cron or fixed intervals\n- **Sub-second cold starts** for low-latency inference\n\nEverything in Modal is defined as code — no YAML, no Dockerfiles required (though both are supported).\n\n## When to Use This Skill\n\nUse this skill when:\n- Deploy or serve AI\u002FML models in the cloud\n- Run GPU-accelerated computations (training, inference, fine-tuning)\n- Create serverless web APIs or endpoints\n- Scale batch processing jobs in parallel\n- Schedule recurring tasks (data pipelines, retraining, scraping)\n- Need persistent cloud storage for model weights or datasets\n- Want to run code in custom container environments\n- Build job queues or async task processing systems\n\n## Installation and Authentication\n\n### Install\n\n```bash\nuv pip install modal\n```\n\nThe Modal Python SDK supports Python 3.10–3.14. This skill targets the stable `modal>=1.0` API (current release: 1.4.x).\n\n### Authenticate\n\nPrefer existing credentials before creating new ones. Only the two Modal-specific\nvariables below are relevant — do not read, load, or expose any other environment\nvariables or `.env` file contents:\n\n1. Check whether `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` are already set in the current environment.\n2. If not, look up only those two keys in a local `.env` file (ignore all other entries) and load them if appropriate for the workflow.\n3. Only fall back to interactive `modal setup` or generating fresh tokens if neither source already provides those two values.\n\n```bash\nmodal setup\n```\n\nThis opens a browser for authentication. For CI\u002FCD or headless environments, use environment variables:\n\n```bash\nexport MODAL_TOKEN_ID=\u003Cyour-token-id>\nexport MODAL_TOKEN_SECRET=\u003Cyour-token-secret>\n```\n\nIf tokens are not already available in the environment or `.env`, generate them at https:\u002F\u002Fmodal.com\u002Fsettings\n\nModal offers a free tier with $30\u002Fmonth in credits.\n\n**Reference**: See `references\u002Fgetting-started.md` for detailed setup and first app walkthrough.\n\n## Core Concepts\n\n### App and Functions\n\nA Modal `App` groups related functions. Functions decorated with `@app.function()` run remotely in the cloud:\n\n```python\nimport modal\n\napp = modal.App(\"my-app\")\n\n@app.function()\ndef square(x):\n    return x ** 2\n\n@app.local_entrypoint()\ndef main():\n    # .remote() runs in the cloud\n    print(square.remote(42))\n```\n\nRun with `modal run script.py`. Deploy with `modal deploy script.py`.\n\n**Reference**: See `references\u002Ffunctions.md` for lifecycle hooks, classes, `.map()`, `.spawn()`, and more.\n\n### Container Images\n\nModal builds container images from Python code. The recommended package installer is `uv`:\n\n```python\nimage = (\n    modal.Image.debian_slim(python_version=\"3.11\")\n    .uv_pip_install(\"torch==2.12.0\", \"transformers==5.9.0\", \"accelerate==1.13.0\")\n    .apt_install(\"git\")\n)\n\n@app.function(image=image)\ndef inference(prompt):\n    from transformers import pipeline\n    pipe = pipeline(\"text-generation\", model=\"meta-llama\u002FLlama-3-8B\")\n    return pipe(prompt)\n```\n\nKey image methods:\n- `.uv_pip_install()` — Install Python packages with uv (recommended)\n- `.pip_install()` — Install with pip (fallback)\n- `.apt_install()` — Install system packages\n- `.run_commands()` — Run shell commands during build\n- `.run_function()` — Run Python during build (e.g., download model weights)\n- `.add_local_python_source()` — Add local modules\n- `.env()` — Set environment variables\n\n**Reference**: See `references\u002Fimages.md` for Dockerfiles, micromamba, caching, GPU build steps.\n\n### GPU Compute\n\nRequest GPUs via the `gpu` parameter:\n\n```python\n@app.function(gpu=\"H100\")\ndef train_model():\n    import torch\n    device = torch.device(\"cuda\")\n    # GPU training code here\n\n# Multiple GPUs\n@app.function(gpu=\"H100:4\")\ndef distributed_training():\n    ...\n\n# GPU fallback chain\n@app.function(gpu=[\"H100\", \"A100-80GB\", \"A100-40GB\"])\ndef flexible_inference():\n    ...\n```\n\nAvailable GPUs: T4, L4, A10, L40S, A100-40GB, A100-80GB, RTX-PRO-6000, H100, H200, B200, B200+\n\n- GPUs are always specified as **strings** (e.g. `gpu=\"H100\"`, `gpu=\"H100:4\"`). The old `modal.gpu.*` objects are deprecated as of v0.73.31.\n- Up to 8 GPUs per container (except A10: up to 4)\n- L40S is recommended for inference (cost\u002Fperformance balance, 48 GB VRAM)\n- H100\u002FA100 can be auto-upgraded to H200\u002FA100-80GB at no extra cost\n- Use `gpu=\"H100!\"` to prevent auto-upgrade\n\n**Reference**: See `references\u002Fgpu.md` for GPU selection guidance and multi-GPU training.\n\n### Volumes (Persistent Storage)\n\nVolumes provide distributed, persistent file storage:\n\n```python\nvol = modal.Volume.from_name(\"model-weights\", create_if_missing=True)\n\n@app.function(volumes={\"\u002Fdata\": vol})\ndef save_model():\n    # Write to the mounted path\n    with open(\"\u002Fdata\u002Fmodel.pt\", \"wb\") as f:\n        torch.save(model.state_dict(), f)\n\n@app.function(volumes={\"\u002Fdata\": vol})\ndef load_model():\n    model.load_state_dict(torch.load(\"\u002Fdata\u002Fmodel.pt\"))\n```\n\n- Optimized for write-once, read-many workloads (model weights, datasets)\n- CLI access: `modal volume ls`, `modal volume put`, `modal volume get`\n- Background auto-commits every few seconds\n- Mount read-only or limit to a subdirectory with `vol.with_mount_options(read_only=True, sub_path=\"subset\")`\n\n**Reference**: See `references\u002Fvolumes.md` for v2 volumes, concurrent writes, and best practices.\n\n### Secrets\n\nSecurely pass credentials to functions:\n\n```python\n@app.function(secrets=[modal.Secret.from_name(\"my-api-keys\")])\ndef call_api():\n    import os\n    api_key = os.environ[\"API_KEY\"]\n    # Use the key\n```\n\nCreate secrets via CLI: `modal secret create my-api-keys API_KEY=sk-xxx`\n\nOr from a `.env` file: `modal.Secret.from_dotenv()`\n\n**Reference**: See `references\u002Fsecrets.md` for dashboard setup, multiple secrets, and templates.\n\n### Web Endpoints\n\nServe models and APIs as web endpoints:\n\n```python\n@app.function()\n@modal.fastapi_endpoint()\ndef predict(text: str):\n    return {\"result\": model.predict(text)}\n```\n\n- `modal serve script.py` — Development with hot reload and temporary URL\n- `modal deploy script.py` — Production deployment with permanent URL\n- Supports FastAPI, ASGI (Starlette, FastHTML), WSGI (Flask, Django), WebSockets\n- Request bodies up to 4 GiB, unlimited response size\n\n**Reference**: See `references\u002Fweb-endpoints.md` for ASGI\u002FWSGI apps, streaming, auth, and WebSockets.\n\n### Scheduled Jobs\n\nRun functions on a schedule:\n\n```python\n@app.function(schedule=modal.Cron(\"0 9 * * *\"))  # Daily at 9 AM UTC\ndef daily_pipeline():\n    # ETL, retraining, scraping, etc.\n    ...\n\n@app.function(schedule=modal.Period(hours=6))\ndef periodic_check():\n    ...\n```\n\nDeploy with `modal deploy script.py` to activate the schedule.\n\n- `modal.Cron(\"...\")` — Standard cron syntax, stable across deploys\n- `modal.Period(hours=N)` — Fixed interval, resets on redeploy\n- Monitor runs in the Modal dashboard\n\n**Reference**: See `references\u002Fscheduled-jobs.md` for cron syntax and management.\n\n### Scaling and Concurrency\n\nModal autoscales containers automatically. Configure limits:\n\n```python\n@app.function(\n    max_containers=100,    # Upper limit\n    min_containers=2,      # Keep warm for low latency\n    buffer_containers=5,   # Reserve capacity\n    scaledown_window=300,  # Idle seconds before shutdown\n)\ndef process(data):\n    ...\n```\n\nProcess inputs in parallel with `.map()`:\n\n```python\nresults = list(process.map([item1, item2, item3, ...]))\n```\n\nEnable concurrent request handling per container with `@modal.concurrent`. Set\n`target_inputs` (the autoscaler's per-container target) below `max_inputs` (the hard\ncap) to keep headroom while scaling up:\n\n```python\n@app.function()\n@modal.concurrent(max_inputs=10, target_inputs=8)\nasync def handle_request(req):\n    ...\n```\n\nReconfigure a deployed Function or Cls at invocation time without redeploying using\n`Function.with_options()` \u002F `Function.with_concurrency()` \u002F `Function.with_batching()`\n(and `Cls.with_options()`):\n\n```python\nModel = modal.Cls.from_name(\"my-app\", \"Model\")\nfast = Model.with_options(gpu=\"H200\", max_containers=20)\nfast().generate.remote(prompt)\n```\n\n**Reference**: See `references\u002Fscaling.md` for `.map()`, `.starmap()`, `.spawn()`, and limits.\n\n### Resource Configuration\n\n```python\n@app.function(\n    cpu=4.0,              # Physical cores (not vCPUs)\n    memory=16384,         # MiB\n    ephemeral_disk=51200, # MiB (up to 3 TiB)\n    timeout=3600,         # Seconds\n)\ndef heavy_computation():\n    ...\n```\n\nDefaults: 0.125 CPU cores, 128 MiB memory. Billed on max(request, usage).\n\n**Reference**: See `references\u002Fresources.md` for limits and billing details.\n\n## Classes with Lifecycle Hooks\n\nFor stateful workloads (e.g., loading a model once and serving many requests):\n\n```python\n@app.cls(gpu=\"L40S\", image=image)\nclass Predictor:\n    @modal.enter()\n    def load_model(self):\n        self.model = load_heavy_model()  # Runs once on container start\n\n    @modal.method()\n    def predict(self, text: str):\n        return self.model(text)\n\n    @modal.exit()\n    def cleanup(self):\n        ...  # Runs on container shutdown\n```\n\nCall with: `Predictor().predict.remote(\"hello\")`\n\n## Sandboxes\n\nFor running untrusted or dynamically generated code (for example, AI-agent output or a code interpreter), use a `modal.Sandbox` — an isolated container you create and control programmatically rather than a decorated Function:\n\n```python\napp = modal.App.lookup(\"sandbox-demo\", create_if_missing=True)\n\n# Isolated container; restrict egress for untrusted workloads\nsb = modal.Sandbox.create(\n    app=app,\n    image=modal.Image.debian_slim(),\n    outbound_cidr_allowlist=[\"10.0.0.0\u002F8\"],\n)\n\n# Stream files in\u002Fout via the filesystem API (beta)\nsb.filesystem.write_text(\"print(2 ** 10)\\n\", \"\u002Ftmp\u002Fjob.py\")\ncontents = sb.filesystem.read_text(\"\u002Ftmp\u002Fjob.py\")\n\nsb.terminate()\n```\n\n- Run commands inside the sandbox with its `exec` method (e.g. run `python \u002Ftmp\u002Fjob.py`) and read stdout from the returned process handle — see `references\u002Fapi_reference.md`\n- Restrict connectivity with `outbound_cidr_allowlist=[...]` \u002F `inbound_cidr_allowlist=[...]`\n- Snapshot the filesystem with `sb.snapshot_filesystem()` to reuse as a base image\n- Ideal for code interpreters, agent tool execution, and per-user isolation\n\n## Common Workflow Patterns\n\n### GPU Model Inference Service\n\n```python\nimport modal\n\napp = modal.App(\"llm-service\")\n\nimage = (\n    modal.Image.debian_slim(python_version=\"3.11\")\n    .uv_pip_install(\"vllm\")\n)\n\n@app.cls(gpu=\"H100\", image=image, min_containers=1)\nclass LLMService:\n    @modal.enter()\n    def load(self):\n        from vllm import LLM\n        self.llm = LLM(model=\"meta-llama\u002FLlama-3-70B\")\n\n    @modal.method()\n    @modal.fastapi_endpoint(method=\"POST\")\n    def generate(self, prompt: str, max_tokens: int = 256):\n        outputs = self.llm.generate([prompt], max_tokens=max_tokens)\n        return {\"text\": outputs[0].outputs[0].text}\n```\n\n### Batch Processing Pipeline\n\n```python\napp = modal.App(\"batch-pipeline\")\nvol = modal.Volume.from_name(\"pipeline-data\", create_if_missing=True)\n\n@app.function(volumes={\"\u002Fdata\": vol}, cpu=4.0, memory=8192)\ndef process_chunk(chunk_id: int):\n    import pandas as pd\n    df = pd.read_parquet(f\"\u002Fdata\u002Finput\u002Fchunk_{chunk_id}.parquet\")\n    result = heavy_transform(df)\n    result.to_parquet(f\"\u002Fdata\u002Foutput\u002Fchunk_{chunk_id}.parquet\")\n    return len(result)\n\n@app.local_entrypoint()\ndef main():\n    chunk_ids = list(range(100))\n    results = list(process_chunk.map(chunk_ids))\n    print(f\"Processed {sum(results)} total rows\")\n```\n\n### Scheduled Data Pipeline\n\n```python\napp = modal.App(\"etl-pipeline\")\n\n@app.function(\n    schedule=modal.Cron(\"0 *\u002F6 * * *\"),  # Every 6 hours\n    secrets=[modal.Secret.from_name(\"db-credentials\")],\n)\ndef etl_job():\n    import os\n    db_url = os.environ[\"DATABASE_URL\"]\n    # Extract, transform, load\n    ...\n```\n\n## CLI Reference\n\n| Command | Description |\n|---------|-------------|\n| `modal setup` | Authenticate with Modal |\n| `modal run script.py` | Run a script's local entrypoint |\n| `modal serve script.py` | Dev server with hot reload |\n| `modal deploy script.py` | Deploy to production |\n| `modal volume ls \u003Cname>` | List files in a volume |\n| `modal volume put \u003Cname> \u003Cfile>` | Upload file to volume |\n| `modal volume get \u003Cname> \u003Cfile>` | Download file from volume |\n| `modal secret create \u003Cname> K=V` | Create a secret |\n| `modal secret list` | List secrets |\n| `modal app list` | List deployed apps |\n| `modal app stop \u003Cname>` | Stop a deployed app |\n\n## Security Notes\n\n- **Credentials:** Only `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` are needed to authenticate. Do not read, log, or forward any other environment variables or `.env` entries.\n- **Subprocess \u002F custom servers:** Some patterns here (multi-GPU training launchers, `@modal.web_server` apps) call `subprocess.run`\u002F`subprocess.Popen` or shell commands during builds. Keep argument lists fixed and hardcoded. Never construct subprocess or shell arguments from unsanitized user input — pass untrusted values as data (files, env vars, stdin), not as command arguments.\n- **Untrusted code:** Run user- or model-generated code inside a `modal.Sandbox` (see above), not a regular Function, and restrict network access with CIDR allowlists.\n\n## Reference Files\n\nDetailed documentation for each topic:\n\n- `references\u002Fgetting-started.md` — Installation, authentication, first app\n- `references\u002Ffunctions.md` — Functions, classes, lifecycle hooks, remote execution\n- `references\u002Fimages.md` — Container images, package installation, caching\n- `references\u002Fgpu.md` — GPU types, selection, multi-GPU, training\n- `references\u002Fvolumes.md` — Persistent storage, file management, v2 volumes\n- `references\u002Fsecrets.md` — Credentials, environment variables, dotenv\n- `references\u002Fweb-endpoints.md` — FastAPI, ASGI\u002FWSGI, streaming, auth, WebSockets\n- `references\u002Fscheduled-jobs.md` — Cron, periodic schedules, management\n- `references\u002Fscaling.md` — Autoscaling, concurrency, .map(), limits\n- `references\u002Fresources.md` — CPU, memory, disk, timeout configuration\n- `references\u002Fexamples.md` — Common use cases and patterns\n- `references\u002Fapi_reference.md` — Key API classes and methods\n\nRead these files when detailed information is needed beyond this overview.\n",{"name":5,"license":15,"metadata":24,"description":7},{"version":25,"openclaw":26,"skill-author":38},"1.2",{"envVars":27},[28,32,35],{"name":29,"required":30,"description":31},"MODAL_TOKEN_ID",true,"Modal token id.",{"name":33,"required":30,"description":34},"MODAL_TOKEN_SECRET","Modal token secret.",{"name":36,"required":20,"description":37},"DATABASE_URL","Optional database URL for examples.","K-Dense Inc.","main","4e084e84eb42fc53e144c89c0f7f48b39c8a4b0f","skills\u002Fmodal",1,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fsanjeevafk","First make it work. Then make it right. Then make it fast.","2026-11-14 13:36:16",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":30},[49,52,55],{"tool":50,"command":51},"npx","npx skills add sanjeevafk\u002Fagent-skills --skill modal",{"tool":53,"command":54},"bunx","bunx skills add sanjeevafk\u002Fagent-skills --skill modal",{"tool":56,"command":57},"pnpm","pnpm dlx skills add sanjeevafk\u002Fagent-skills --skill modal","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002FSKILL.md",[60,66,70,74,78,82,86,90,94,98,102,106],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fapi_reference.md","REFERENCE","参考文档",6847,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fapi_reference.md",{"path":67,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fexamples.md",7493,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fexamples.md",{"path":71,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Ffunctions.md",5793,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Ffunctions.md",{"path":75,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fgetting-started.md",4060,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fgetting-started.md",{"path":79,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fgpu.md",5068,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fgpu.md",{"path":83,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fimages.md",6681,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fimages.md",{"path":87,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fresources.md",2581,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fresources.md",{"path":91,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fscaling.md",4556,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fscaling.md",{"path":95,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fscheduled-jobs.md",3777,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fscheduled-jobs.md",{"path":99,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Fsecrets.md",2874,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fsecrets.md",{"path":103,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Fvolumes.md",5806,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fvolumes.md",{"path":107,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":108,"sourceHtmlUrl":109},"references\u002Fweb-endpoints.md",5857,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmodal\u002Freferences\u002Fweb-endpoints.md",[111,119,127,135,143,150],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":115,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":19},"01M7EFHX67M3KKXT1BXVPA5ADT","zarr-python","Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I\u002FO, S3\u002FGCS via fsspec, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","MIT","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":115,"licenseFileUrl":123,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":19},"01M7EFFQGM51TZBGRENXY50ZYM","whiteboard-diagrams","Create accurate, simple, hand-drawn whiteboard diagrams from a user's process, system, architecture, learning workflow, comparison, or causal explanation. Use when the user asks for a scribbly whiteboard visual, educational workflow graphic, hand-drawn explainer, or diagram like the bundled reference; ask one focused clarification question when the subject or relationships are missing, then generate and visually verify the final image.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FSKILL.md",[],[],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":131,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":19},"01M7EFF1CSQNTDMHFK4ZGY6NYK","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":139,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":19},"01M7EFE8106X6C28FT8PA74427","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":115,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":19},"01M7EFCSNZM9G7ZHS6F127Q71X","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":115,"licenseFileUrl":154,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":19},"01M7EFCE7EZMKPRYDDNKBQ9EEH","vercel-deploy","Deploy applications and websites to Vercel. Use when the user requests deployment actions like \"deploy my app\", \"deploy and give me the link\", \"push this live\", or \"create a preview deployment\".","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FSKILL.md",[],[]]