modal

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Overview

概述

This is a foundational skill for working with the Modal cloud platform.
Modal is a platform for AI workloads. It offers highly scalable serverless compute (including GPUs) with minimal configuration.
本技能是使用Modal云平台的基础技能。
Modal是一款面向AI工作负载的平台。它提供高度可扩展的无服务器计算(包括GPU),且配置需求极少。

Documentation

文档

The official docs are the best source for up-to-date information on the platform. Make use of them when planning, debugging, or answering questions!
Modal's documentation is outlined at https://modal.com/llms.txt. This file contains titles and URLs for all public docs; reading it directly will guide you to specific content.
The docs are divided into three sections:
  • Guide pages have explanations of Modal features, primitives, and workflows
  • API Reference pages have detailed information about each component of the SDK
  • Examples pages contain didactic examples of various AI applications on Modal
Fetch the docs using a
.md
extension to get plain text.
If this skill has been installed via the
modal
CLI, the docs are also bundled locally under
references/
.
You can also refer to https://modal.com/llms-full.txt, which aggregates all docs in a single very large file. Do not read this into your main context, but it may be useful for searching.
官方文档是获取平台最新信息的最佳来源。在规划、调试或解答问题时,请充分利用官方文档!
文档分为三个部分:
  • _指南_页面:讲解Modal的功能、基本元素和工作流程
  • _API参考_页面:包含SDK各组件的详细信息
  • _示例_页面:包含基于Modal构建的各类AI应用的教学示例
使用.md扩展名获取文档,以获得纯文本格式。
如果本技能是通过
modal
CLI安装的,文档也会本地捆绑在
references/
目录下。

Using the CLI

使用CLI

The
modal
CLI can be used to run or deploy code, manage resources, and observe running Apps. It is a key tool for interacting with Modal throughout all stages of development.
Run
modal --help
to see all available CLI commands.
You can see more detailed information about each command by running
modal [command] --help
. Rely on the
--help
to discover functionality: new features are added in every release! Always check the
--help
if you encounter a usage error.
Tip: many CLI commands accept a
--json
flag to make their output more easily parseable, e.g. with
jq
.
The
modal
CLI is part of the Python SDK and executes in a Python runtime. Depending on the user's preferred Python development workflow, you may need to prefix
modal
CLI invocations with, e.g.,
uv run
to ensure a consistent Python environment. The CLI can also be used via
uvx
as a standalone tool, but only do this when working outside of a Python project.
modal
CLI可用于运行或部署代码、管理资源以及监控运行中的应用。它是开发全阶段与Modal交互的关键工具。
运行
modal --help
查看所有可用的CLI命令。
运行
modal [command] --help
可查看每个命令的详细信息。借助
--help
探索功能:每个版本都会新增功能!如果遇到使用错误,请务必查看
--help
提示:许多CLI命令支持
--json
标志,使输出更易于解析,例如配合
jq
使用。
modal
CLI是Python SDK的一部分,在Python运行时中执行。根据用户偏好的Python开发工作流,你可能需要在
modal
CLI调用前添加前缀,例如
uv run
,以确保一致的Python环境。也可通过
uvx
将CLI作为独立工具使用,但仅在Python项目外工作时这样做。

Getting up to date

获取最新信息

You have significant knowledge about Modal from your training data but may not be aware of new features or recent changes to the API. Modal is continuously adding new features. Reading relevant docs while planning or debugging can help you discover the most up-to-date way to accomplish a task on Modal.
The Modal CLI provides a
modal changelog
command for learning about recent changes. Useful invocation patterns:
  • modal changelog --since [DATE]
    to see changes added since your knowledge cutoff
  • modal changelog --since [VERSION]
    when migrating a codebase to a newer version
  • modal changelog --newer
    to discover features that would be available on update
Note:
modal changelog
requires network access.
Run
modal --version
to see the SDK version that is in use.
If your code exercises deprecated APIs, Modal will issue warnings. Use the warning message and related documentation to migrate your code to stable API.
This skill will also be improved over time. Its version should correspond to the version of the Modal SDK that you are using. If the skill is out of date, it can be updated by running
modal skills update
.
你的训练数据包含大量关于Modal的知识,但可能不了解新增功能或API的最新变更。Modal一直在持续添加新功能。在规划或调试时阅读相关文档,有助于你发现在Modal上完成任务的最新方法。
Modal CLI提供
modal changelog
命令,用于了解近期变更。实用的调用方式:
  • modal changelog --since [DATE]
    :查看自你的知识截止日期以来的变更
  • modal changelog --since [VERSION]
    :在将代码库迁移到新版本时使用
  • modal changelog --newer
    :发现更新后可用的功能
注意:
modal changelog
需要网络访问。
运行
modal --version
查看当前使用的SDK版本。
如果你的代码使用了已弃用的API,Modal会发出警告。请使用警告信息和相关文档将代码迁移到稳定API。
本技能也会不断改进。其版本应与你使用的Modal SDK版本对应。如果技能已过时,可通过运行
modal skills update
进行更新。

Auth

身份验证

Modal is a cloud platform. Using the CLI or running code that depends on the
modal
library requires internet access and an authorization token. There is no "local development mode" with Modal.
You can use the
modal token
CLI to create a new token (note: this workflow requires human user involvement) or to debug authorization issues. Token setup only needs to happen once, so assume it is configured unless you encounter issues.
Modal是一个云平台。使用CLI或运行依赖
modal
库的代码需要互联网访问权限和授权令牌。Modal没有“本地开发模式”。
你可以使用
modal token
CLI创建新令牌(注意:此流程需要人工用户参与)或调试身份验证问题。令牌设置只需进行一次,因此除非遇到问题,否则默认已配置完成。

Async Python

异步Python

When writing async Python, use Modal's
.aio()
interface (e.g.
await modal.Sandbox.create.aio(...)
,
await modal.Function.remote.aio(...)
) so that Modal runs its I/O operations via asynchronous coroutines.
编写异步Python代码时,请使用Modal的
.aio()
接口(例如
await modal.Sandbox.create.aio(...)
await modal.Function.remote.aio(...)
),以便Modal通过异步协程运行其I/O操作。

Other languages

其他语言

Python is currently the only runtime language for Modal Functions, but there are Modal SDKs in both JavaScript (TypeScript) and Go:
The Go / JS SDKs are not as mature as the Python SDK and may be missing features. The current scope for the Go / JS SDKs includes (1) creating and interacting with Sandboxes and (2) calling into deployed Modal Functions (i.e., Functions defined in Python).
They are primarily documented through examples hosted on GitHub rather than through the main Modal docs. You likely have much less knowledge of these SDKs from your training, so rely on these examples.
Python目前是Modal Functions唯一的运行时语言,但Modal也提供JavaScript(TypeScript)和Go版本的SDK:
Go/JS SDK的成熟度不如Python SDK,可能缺少部分功能。当前Go/JS SDK的适用范围包括:(1) 创建和交互沙箱;(2) 调用已部署的Modal Functions(即Python中定义的函数)。
它们主要通过GitHub上托管的示例进行文档说明,而非Modal主文档。你的训练数据中关于这些SDK的知识可能较少,因此请依赖这些示例。