Skip to main content
These examples use a CoreWeave API access token in CWSANDBOX_API_KEY. For Forge API key authentication, see Get started. For CKS requirements, see Placement modes. This tutorial shows you how to run Python functions inside a sandbox using remote functions. You can call sandbox-executed code as if it were a local function instead of constructing shell command strings. It’s for developers who want to invoke compute in a sandbox directly from their Python code and collect typed results.

Define and call a remote function

Decorate a function with @session.function() to call it inside the sandbox with .remote(). The call returns a reference you resolve with .result():

Run functions in parallel with .map()

Use .map() to dispatch many invocations at once and collect their results. Independent calls run concurrently instead of one at a time:

Next steps

You can now invoke Python functions inside a sandbox as if they were local calls, and fan out work in parallel with .map(). For serialization modes, .local() testing, and more, see the Remote functions guide.
Last modified on October 14, 2026