> ## Documentation Index
> Fetch the complete documentation index at: https://docs.costgraph.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Lightning AI sandboxes

> Run CostGraph workflows and CI jobs in Lightning AI sandboxes: the key to create, its permissions, and its limits

Lightning AI Sandbox gives each workload its own isolated, on-demand Linux environment with its own filesystem, network stack and dedicated compute, which you create and control programmatically.

The following table shows what CostGraph runs on this provider.

| Workflows | CI runners | Connect with |
| - | - | - |
| Yes | No | Integrations or your own dispatcher |

CI runners: no. AutoPilot compares runners by price, and this provider publishes no sandbox price.

## Connect

Connect Lightning AI on Integrations, and CostGraph starts sandboxes in your Lightning AI account. You don't run anything yourself.

1. In CostGraph, go to **Integrations > Sandbox > Lightning AI**.

2. Enter these fields:

   * **API key** (`LIGHTNING_SANDBOX_API_KEY`, required): A Lightning AI API key scoped to the teamspace sandboxes run in.

3. Click **Connect**.

### Your own dispatcher

To keep the key out of CostGraph or reach a private network, run your own dispatcher instead.
Set `provider` to `lightning` and the preceding fields as environment variables, as described in [Run your own dispatcher](https://docs.costgraph.ai/costgraph/workflows/managed-sandboxes.md#run-your-own-dispatcher).

## Key and permissions

LIGHTNING\_SANDBOX\_API\_KEY (preferred; LIGHTNING\_API\_KEY is the legacy fallback) is a Lightning AI API key. Create it in settings under Members > API keys > Create API Key, choosing a role and the teamspace to scope it to. The key alone selects the teamspace.

Partly documented: use a teamspace-scoped (project-scoped) key. With an org-scoped key, sandbox creation works but snapshot and persistence calls fail. Key creation asks for a role, but the docs do not say which role is the minimum for sandboxes (the RBAC page lists Admin, Member and Guest without mentioning API keys).

Sources: [lightning.ai: sandbox](https://lightning.ai/docs/platform/build/sandbox/), [lightning.ai: sandbox](https://lightning.ai/docs/platform/developers/sdk/sandbox), [lightning.ai: js sandbox sdk](https://lightning.ai/docs/platform/developers/sdk/sandbox/js-sandbox-sdk), [lightning.ai: role based access controls](https://lightning.ai/docs/platform/team-management/organizations/role-based-access-controls).

## Limits

* The timeout option at create is the initial auto-stop deadline in ms (0 = no timeout). extendTimeout(ms) adds to it (minimum 1000 ms). No default or maximum is documented. ([source](https://lightning.ai/docs/platform/developers/sdk/sandbox/js-sandbox-sdk))
* Machine slugs: cpu-1 1 vCPU/1 GB, cpu-2 2/8 GB, cpu-4 4/16 GB, cpu-8 8/32 GB, cpu-16 16/64 GB. ([source](https://lightning.ai/docs/platform/build/sandbox/))
* Sandboxes are persistent: they save their state on stop and resume where they left off. The docs do not state regions, CPU architecture or preview status. ([source](https://lightning.ai/docs/platform/build/sandbox/))

## Related

* [Supported sandbox providers](https://docs.costgraph.ai/costgraph/workflows/sandbox-providers.md)
* [Run workflows on a managed sandbox provider](https://docs.costgraph.ai/costgraph/workflows/managed-sandboxes.md)
* [Run CI jobs in sandboxes](https://docs.costgraph.ai/costgraph/autopilot/ci-sandboxes.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.