---
title: Studio
description: A single Lightning AI Studio.
canonical: 'https://lightning.ai/docs/sdk/stable/api/studio'
---
# Studio {#studio}

### `class lightning_sdk.Studio(name=None, teamspace=None, org=None, user=None, cloud=None, create_ok=True, source=None, disable_secrets=False, studio_type=None)` {#lightning_sdk.Studio}

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object "(in Python v3.15)")

A single Lightning AI Studio.

Allows to fully control a studio, including retrieving the status, running commands and switching machine types.

Parameters:

*   **name** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – the name of the studio
    
*   **teamspace** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Teamspace`](/docs/sdk/2026.11.04/api/teamspace.md#lightning_sdk.Teamspace "lightning_sdk.teamspace.Teamspace"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – the name of the teamspace the studio is contained by. Accepts a bare name or an `owner/teamspace` slug.
    
*   **org** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Organization`](/docs/sdk/2026.11.04/api/organization.md#lightning_sdk.Organization "lightning_sdk.organization.Organization"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – the name of the organization owning the the teamspace in case it is owned by an org. Deprecated — pass the owner as part of `teamspace` instead, e.g. `teamspace="owner/teamspace"`.
    
*   **user** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`User`](/docs/sdk/2026.11.04/api/user.md#lightning_sdk.User "lightning_sdk.user.User"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – the name of the user owning the the teamspace in case it is owned directly by a user instead of an org. Deprecated — pass the owner as part of `teamspace` instead, e.g. `teamspace="owner/teamspace"`.
    
*   **cloud** (`Union`\[[`CloudProvider`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.CloudProvider "lightning_sdk.machine.CloudProvider"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Cloud provider or cloud account to create the studio on.
    
*   **create\_ok** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – whether the studio will be created if it does not yet exist. Defaults to True
    
*   **studio\_type** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Type of studio to create: a base studio template id or name. Defaults to the current studio’s template when creating from inside a Studio in the same teamspace, otherwise to the first enabled template. Only effective during initial creation; ignored for existing studios.
    
*   **name** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    
*   **teamspace** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ [_Teamspace_](/docs/sdk/2026.11.04/api/teamspace.md#lightning_sdk.Teamspace "lightning_sdk.teamspace.Teamspace") _|_ _None_)
    
*   **org** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ [_Organization_](/docs/sdk/2026.11.04/api/organization.md#lightning_sdk.Organization "lightning_sdk.organization.Organization") _|_ _None_)
    
*   **user** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ [_User_](/docs/sdk/2026.11.04/api/user.md#lightning_sdk.User "lightning_sdk.user.User") _|_ _None_)
    
*   **cloud** ([_CloudProvider_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.CloudProvider "lightning_sdk.machine.CloudProvider") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    
*   **create\_ok** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **source** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    
*   **disable\_secrets** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **studio\_type** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    

Note

Since a teamspace can either be owned by an org or by a user directly, only one of the arguments can be provided.

#### `add_ports(ports)` {#lightning_sdk.Studio.add_ports}

Add one or more ports to the studio and return their endpoints.

Parameters:

*   **ports** (`Union`\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"), [`List`](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\], [`Dict`](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]\]) – Port to add. Can be: - int: Single port (e.g., 8080) - List\[int\]: Multiple ports () - dict\[str, int\]: Named ports (e.g., {“web”: 8080})
    
*   **ports** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)") _|_ [_List_](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.15)")_\[_[_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")_\]_ _|_ [_Dict_](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")_\]_)
    

Return type:

[`List`](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.15)")\[`V1Endpoint`\]

Returns:

Endpoints for the added ports. Each entry exposes `name`, `ports`, and `urls` attributes.

#### `create_assistant(name, port)` {#lightning_sdk.Studio.create_assistant}

Create a Lightning AI assistant backed by a service running on this Studio.

Parameters:

*   **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Display name for the assistant.
    
*   **port** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – The port on this Studio that serves the assistant endpoint.
    
*   **name** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **port** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"))
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

Returns:

`None`; the assistant ID is stored on the instance for later use.

#### `delete()` {#lightning_sdk.Studio.delete}

Deletes the current Studio.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `delete_env(key)` {#lightning_sdk.Studio.delete_env}

Delete one directly configured Studio environment variable.

Parameters:

*   **key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Name of the environment variable to delete.
    
*   **key** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    

Raises:

[**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If the name is invalid or is not directly configured.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `download_file(remote_path, file_path=None)` {#lightning_sdk.Studio.download_file}

Downloads a file from the Studio to a given target path.

Parameters:

*   **remote\_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Path of the file inside the Studio to download.
    
*   **file\_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Local destination path. Defaults to `remote_path`.
    
*   **remote\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **file\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `download_folder(remote_path, target_path=None)` {#lightning_sdk.Studio.download_folder}

Downloads a folder from the Studio to a given target path.

Parameters:

*   **remote\_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Path of the directory inside the Studio to download.
    
*   **target\_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Local destination directory. Defaults to `remote_path`.
    
*   **remote\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **target\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `duplicate(target_teamspace=None, machine=Machine(name='CPU', slug='cpu-4', instance_type=None, family='CPU', accelerator_count=4, cost=None, interruptible_cost=None, provider=None, wait_time=None, interruptible_wait_time=None, _include_in_cli=True), name=None)` {#lightning_sdk.Studio.duplicate}

Duplicates the existing Studio.

Parameters:

*   **target\_teamspace** (`Union`\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Teamspace`](/docs/sdk/2026.11.04/api/teamspace.md#lightning_sdk.Teamspace "lightning_sdk.teamspace.Teamspace"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – the teamspace to duplicate the studio to. Must have the same owner as the source teamspace. If not provided, defaults to current teamspace.
    
*   **machine** ([`Machine`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine")) – the machine to start the duplicated studio on. Defaults to CPU
    
*   **target\_teamspace** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ [_Teamspace_](/docs/sdk/2026.11.04/api/teamspace.md#lightning_sdk.Teamspace "lightning_sdk.teamspace.Teamspace") _|_ _None_)
    
*   **machine** ([_Machine_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine"))
    
*   **name** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    

Returns:

The newly created duplicate Studio.

Return type:

[Studio](#lightning_sdk.Studio "lightning_sdk.Studio")

Raises:

[**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If the target teamspace cannot be resolved.

#### `list_ports()` {#lightning_sdk.Studio.list_ports}

List ports that are exposed in the Studio.

Returns:

The currently exposed port endpoints.

Return type:

List\[V1Endpoint\]

#### `rename(new_name)` {#lightning_sdk.Studio.rename}

Renames the current Studio to the provided new name.

Parameters:

*   **new\_name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – The new display name for the Studio.
    
*   **new\_name** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `run(*commands)` {#lightning_sdk.Studio.run}

Runs given commands on the Studio while returning only the output.

Parameters:

*   **commands** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – the commands to run on the Studio in sequence.
    
*   **commands** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    

Returns:

The combined stdout output of the commands.

Return type:

[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")

Raises:

[**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If any command exits with a non-zero exit code.

#### `run_and_detach(*commands, timeout=10, check_interval=1)` {#lightning_sdk.Studio.run_and_detach}

Runs given commands on the Studio and returns immediately.

The command will continue to run in the background.

Parameters:

*   **\*commands** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – The shell commands to execute in sequence.
    
*   **timeout** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – Wait for this many seconds for the command to finish. Defaults to `10`.
    
*   **check\_interval** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – Poll the command status every this many seconds. Defaults to `1`.
    
*   **commands** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **timeout** ([_float_](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)"))
    
*   **check\_interval** ([_float_](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)"))
    

Return type:

[`Tuple`](https://docs.python.org/3/library/typing.html#typing.Tuple "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]\]

Returns:

Tuple of (output, exit\_code) collected up to the timeout.

Raises:

*   [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If `check_interval` is greater than `timeout`.
    
*   [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the Studio is not currently running.
    

#### `run_job(name, machine, command, env=None, interruptible=False, reuse_snapshot=True, max_run_attempts=None, keep_minutes=None)` {#lightning_sdk.Studio.run_job}

Run async workloads using the compute environment from your studio.

Parameters:

*   **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – The name of the job. Needs to be unique within the teamspace.
    
*   **machine** (`Union`\[[`Machine`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – The machine type to run the job on.
    
*   **command** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – The command to run inside your job.
    
*   **env** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Dict`](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]\]) – Environment variables to set inside the job.
    
*   **interruptible** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether the job should run on interruptible instances. They are cheaper but can be preempted.
    
*   **reuse\_snapshot** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether the job should reuse a Studio snapshot when multiple jobs for the same Studio are submitted. Turning this off may result in longer job startup times. Defaults to True.
    
*   **max\_run\_attempts** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – Max number of run attempts for this job. `None` or `0` means unset (backend default). `1` means a single attempt (no retries).
    
*   **keep\_minutes** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – Minutes to keep the machine after the job stops. `None` or `0` releases the machine immediately.
    
*   **name** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **machine** ([_Machine_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **command** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **env** ([_Dict_](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_ _|_ _None_)
    
*   **interruptible** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **reuse\_snapshot** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **max\_run\_attempts** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)") _|_ _None_)
    
*   **keep\_minutes** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)") _|_ _None_)
    

Returns:

The submitted [`Job`](/docs/sdk/2026.11.04/api/job.md#lightning_sdk.Job "lightning_sdk.Job") instance.

Return type:

[Job](/docs/sdk/2026.11.04/api/job.md#lightning_sdk.Job "lightning_sdk.Job")

#### `run_mmt(name, num_machines, machine, command, env=None, interruptible=False, max_run_attempts=None, keep_minutes=None)` {#lightning_sdk.Studio.run_mmt}

Run async workloads using the compute environment from your studio.

Parameters:

*   **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – The name of the job. Needs to be unique within the teamspace.
    
*   **num\_machines** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – The number of machines to run on.
    
*   **machine** (`Union`\[[`Machine`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – The machine type to run the job on.
    
*   **command** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – The command to run inside your job.
    
*   **env** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Dict`](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]\]) – Environment variables to set inside the job.
    
*   **interruptible** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether the job should run on interruptible instances. They are cheaper but can be preempted.
    
*   **max\_run\_attempts** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – Max number of run attempts for this multi-machine job. `None` or `0` means unset (legacy, no retries); `1` means a single attempt (no retries). When greater than `1` the `RECREATE_ALL_NODES` fault tolerance strategy is set automatically on the multi-machine job body. Set at the multi-machine job level, not on the per-machine `JobSpec`.
    
*   **keep\_minutes** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – Minutes to keep the machines after the job stops. `None` or `0` releases the machines immediately.
    
*   **name** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **num\_machines** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"))
    
*   **machine** ([_Machine_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **command** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **env** ([_Dict_](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_ _|_ _None_)
    
*   **interruptible** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **max\_run\_attempts** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)") _|_ _None_)
    
*   **keep\_minutes** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)") _|_ _None_)
    

Returns:

The submitted [`MMT`](/docs/sdk/2026.11.04/api/mmt.md#lightning_sdk.MMT "lightning_sdk.MMT") instance.

Return type:

[MMT](/docs/sdk/2026.11.04/api/mmt.md#lightning_sdk.MMT "lightning_sdk.MMT")

#### `run_with_exit_code(*commands)` {#lightning_sdk.Studio.run_with_exit_code}

Runs given commands on the Studio while returning output and exit code.

Parameters:

*   **commands** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – the commands to run on the Studio in sequence.
    
*   **commands** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    

Returns:

A tuple of (output, exit\_code).

Return type:

Tuple\[[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [int](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]

Raises:

[**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the Studio is not currently running.

#### `set_env(new_env, partial=True)` {#lightning_sdk.Studio.set_env}

Set the environment variables for the Studio.

Parameters:

*   **new\_env** ([`Dict`](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – The new environment variables to set.
    
*   **partial** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether to only set the environment variables that are provided. If False, existing environment variables that are not in new\_env will be removed. If True, existing environment variables that are not in new\_env will be kept.
    
*   **new\_env** ([_Dict_](https://docs.python.org/3/library/typing.html#typing.Dict "(in Python v3.15)")_\[_[_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_)
    
*   **partial** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `start(machine=None, interruptible=None, max_runtime=None)` {#lightning_sdk.Studio.start}

Starts a Studio on the specified machine type (default: CPU-4).

Parameters:

*   **machine** (`Union`\[[`Machine`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – the machine type to start the studio on. Defaults to CPU-4
    
*   **interruptible** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")\]) – whether to use interruptible machines
    
*   **max\_runtime** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – the duration (in seconds) for which to allocate the machine. Irrelevant for most machines, required for some of the top-end machines on GCP. If in doubt, set it. Won’t have an effect on machines not requiring it. Defaults to 3h
    
*   **machine** ([_Machine_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    
*   **interruptible** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)") _|_ _None_)
    
*   **max\_runtime** ([_int_](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)") _|_ _None_)
    

Raises:

*   [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the Studio is already running on a different machine or is not stopped.
    
*   [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the requested machine has no available capacity.
    
*   [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the started instance fails or stops before becoming ready.
    

Warns:

**UserWarning** – If the requested machine is not a known machine type for the selected cloud account. It is treated as a custom instance type and passed through as-is.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `stop()` {#lightning_sdk.Studio.stop}

Stops a running Studio.

Raises:

[**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the Studio is not currently running or pending.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `switch_machine(machine, interruptible=False, cloud_provider=None)` {#lightning_sdk.Studio.switch_machine}

Switches machine to the provided machine type/.

Parameters:

*   **machine** (`Union`\[[`Machine`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine"), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – the new machine type to switch to
    
*   **interruptible** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – determines whether to switch to an interruptible instance
    
*   **cloud\_provider** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`CloudProvider`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.CloudProvider "lightning_sdk.machine.CloudProvider")\]) – the cloud provider to switch to, has no effect if the Studio is not on Lightning Cloud
    
*   **machine** ([_Machine_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **interruptible** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **cloud\_provider** ([_CloudProvider_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.CloudProvider "lightning_sdk.machine.CloudProvider") _|_ _None_)
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

Note

this call is blocking until the new machine is provisioned

Raises:

[**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the Studio is not currently running.

Parameters:

*   **machine** ([_Machine_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **interruptible** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    
*   **cloud\_provider** ([_CloudProvider_](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.CloudProvider "lightning_sdk.machine.CloudProvider") _|_ _None_)
    

Return type:

None

#### `upload_file(file_path, remote_path=None, progress_bar=True)` {#lightning_sdk.Studio.upload_file}

Uploads a given file to a remote path on the Studio.

Parameters:

*   **file\_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Local path of the file to upload.
    
*   **remote\_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Destination path inside the Studio. Defaults to the file’s basename.
    
*   **progress\_bar** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether to display a progress bar. Defaults to `True`.
    
*   **file\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **remote\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    
*   **progress\_bar** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `upload_folder(folder_path, remote_path=None, progress_bar=True)` {#lightning_sdk.Studio.upload_folder}

Uploads a given folder to a remote path on the Studio.

Parameters:

*   **folder\_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")) – Local directory to upload.
    
*   **remote\_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – Destination directory inside the Studio. Defaults to preserving the relative structure.
    
*   **progress\_bar** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Whether to display a progress bar. Defaults to `True`.
    
*   **folder\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))
    
*   **remote\_path** ([_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") _|_ _None_)
    
*   **progress\_bar** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)"))
    

Raises:

*   [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If `folder_path` is `None`.
    
*   [**NotADirectoryError**](https://docs.python.org/3/builtins/exceptions.html#NotADirectoryError "(in Python v3.15)") – If `folder_path` is a file or does not exist.
    

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `property auto_shutdown: bool` {#lightning_sdk.Studio.auto_shutdown}

Whether auto-sleep is enabled. Deprecated — use [`auto_sleep`](#lightning_sdk.Studio.auto_sleep "lightning_sdk.Studio.auto_sleep") instead.

Returns:

True if auto-sleep is currently enabled.

Return type:

[bool](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")

#### `property auto_shutdown_time: int` {#lightning_sdk.Studio.auto_shutdown_time}

Idle timeout in seconds before auto-sleep. Deprecated — use [`auto_sleep_time`](#lightning_sdk.Studio.auto_sleep_time "lightning_sdk.Studio.auto_sleep_time") instead.

Returns:

The current idle timeout in seconds.

Return type:

[int](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `property auto_sleep: bool` {#lightning_sdk.Studio.auto_sleep}

Returns if a Studio has auto-sleep enabled.

Returns:

True if auto-sleep is enabled for this Studio.

Return type:

[bool](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")

#### `property auto_sleep_time: int` {#lightning_sdk.Studio.auto_sleep_time}

Returns the time in seconds a Studio has to be idle for auto-sleep to kick in (if enabled).

Returns:

Idle timeout in seconds before auto-sleep activates.

Return type:

[int](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `property cloud_account: str` {#lightning_sdk.Studio.cloud_account}

The cloud account ID this Studio is associated with.

Returns:

The cloud account (cluster) ID.

Return type:

[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")

#### `property cluster: str` {#lightning_sdk.Studio.cluster}

Returns the cluster the Studio is running on.

Returns:

The cloud account (cluster) ID.

Return type:

[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")

#### `property env: Dict[str, str]` {#lightning_sdk.Studio.env}

All environment variables currently set on this Studio.

Returns:

Mapping of environment variable names to their values.

Return type:

[dict](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")\[[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"), [str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]

#### `property id: str` {#lightning_sdk.Studio.id}

The studio’s unique identifier.

#### `property interruptible: bool | None` {#lightning_sdk.Studio.interruptible}

Returns whether the Studio is running on a interruptible instance.

Returns:

True if the Studio is on an interruptible instance, None if not running.

Return type:

[bool](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")

#### `property machine: Machine | None` {#lightning_sdk.Studio.machine}

Returns the current machine type the Studio is running on.

Returns:

The active [`Machine`](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.machine.Machine"), or None if not running.

Return type:

Optional\[[Machine](/docs/sdk/2026.11.04/api/machine.md#lightning_sdk.Machine "lightning_sdk.Machine")\]

#### `property name: str` {#lightning_sdk.Studio.name}

Returns the name of the studio.

Returns:

The studio name.

Return type:

[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")

#### `property owner: Owner` {#lightning_sdk.Studio.owner}

Returns the name of the owner (either user or org).

Returns:

The owning [`Owner`](/docs/sdk/2026.11.04/api/owner.md#lightning_sdk.owner.Owner "lightning_sdk.owner.Owner") (user or org).

Return type:

[Owner](/docs/sdk/2026.11.04/api/owner.md#lightning_sdk.owner.Owner "lightning_sdk.owner.Owner")

#### `property placement_group_id: str | None` {#lightning_sdk.Studio.placement_group_id}

The placement group identifier for this Studio’s current compute, if assigned.

#### `property public_ip: str | None` {#lightning_sdk.Studio.public_ip}

Returns the public IP address of the machine the Studio is running on.

Returns:

The public IP, or None if unavailable.

Return type:

Optional\[[str](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]

#### `property status: Status` {#lightning_sdk.Studio.status}

Returns the Status of the Studio.

Can be one of { NotCreated | Pending | Running | Stopping | Stopped | Failed }

Returns:

The current [`Status`](/docs/sdk/2026.11.04/api/status.md#lightning_sdk.Status "lightning_sdk.status.Status") of the Studio.

Return type:

[Status](/docs/sdk/2026.11.04/api/status.md#lightning_sdk.Status "lightning_sdk.Status")

#### `property teamspace: Teamspace` {#lightning_sdk.Studio.teamspace}

Returns the name of the Teamspace.

Returns:

The [`Teamspace`](/docs/sdk/2026.11.04/api/teamspace.md#lightning_sdk.Teamspace "lightning_sdk.teamspace.Teamspace") this Studio belongs to.

Return type:

[Teamspace](/docs/sdk/2026.11.04/api/teamspace.md#lightning_sdk.Teamspace "lightning_sdk.Teamspace")

---

**Navigation**

- Parent: [API Reference](/docs/sdk/2026.11.04/api.md)
