Choose authentication
These examples run on serverless capacity unless a section specifies CKS. Choose the credential for the account that owns your sandboxes. See Choose and get credentials to obtain a key or token. Run the installation commands in an active Python virtual environment. Save the Python code from your credential tab assandbox_auth.py beside the Python scripts you run from this page. It stores the authentication choice, not your credential. The examples import AUTH from that file and pass it explicitly to each new sandbox or session.
- W&B API key
- CoreWeave API access token
Use your Forge API key through the SDK’s W&B authentication strategy:
sandbox_auth.py
placement_mode="cks" on sandbox creation or in SandboxDefaults. Creating a session with auth=AUTH also authenticates the sandboxes it owns. Keep the same credential when reconnecting, listing, or cleaning up sandboxes.
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.