Documentation Index
Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
Use this file to discover all available pages before exploring further.
Modal provides serverless container infrastructure with GPU support. See the Modal docs for signup, authentication, and platform details.
Installation
pip install langchain-modal
Create a sandbox backend
In Python, you create the sandbox using the provider SDK, then wrap it with the deepagents backend.
import modal
from langchain_modal import ModalSandbox
app = modal.App.lookup("your-app")
modal_sandbox = modal.Sandbox.create(app=app)
backend = ModalSandbox(sandbox=modal_sandbox)
result = backend.execute("echo hello")
print(result.output)
Use with Deep Agents
import modal
from langchain_anthropic import ChatAnthropic
from deepagents import create_deep_agent
from langchain_modal import ModalSandbox
app = modal.App.lookup("your-app")
modal_sandbox = modal.Sandbox.create(app=app)
backend = ModalSandbox(sandbox=modal_sandbox)
agent = create_deep_agent(
model=ChatAnthropic(model="claude-sonnet-4-20250514"),
system_prompt="You are a coding assistant with sandbox access.",
backend=backend,
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Install numpy and calculate pi"}]}
)
Cleanup
You are responsible for managing the sandbox lifecycle via Modal.
When you are done, terminate the sandbox.
See also: Sandboxes.