> For the complete documentation index, see [llms.txt](https://docs.computesdk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.computesdk.com/providers/gravixlayer.md).

# GravixLayer

GravixLayer provider for ComputeSDK — cloud runtimes with a native filesystem, live command streaming, port publishing, templates, and snapshots.

[GravixLayer](https://gravixlayer.ai) provider for ComputeSDK — cloud runtimes with a native filesystem API, live command streaming, port publishing, templates, and snapshots.

## Installation & Setup

```bash
npm install @computesdk/gravixlayer
```

Add your GravixLayer API key to a `.env` file:

```bash
GRAVIXLAYER_API_KEY=your_gravixlayer_api_key
```

Optional:

```bash
GRAVIXLAYER_BASE_URL=https://api.gravixlayer.ai
GRAVIXLAYER_CLOUD=aws
GRAVIXLAYER_REGION=us-east-1
```

Get your API key at [gravixlayer.ai](https://gravixlayer.ai). Product docs: [docs.gravixlayer.ai](https://docs.gravixlayer.ai).

## Usage

```typescript
import { gravixlayer } from '@computesdk/gravixlayer'

const compute = gravixlayer({
  apiKey: process.env.GRAVIXLAYER_API_KEY,
})

const sandbox = await compute.instances.create({
  templateId: 'base-small',
})

const result = await sandbox.runCommand('echo "Hello from GravixLayer!"')
console.log(result.stdout)

await sandbox.destroy()
```

`templateId` selects an existing template. To start from a snapshot, pass `snapshotId` instead (not both). `image` is not accepted; build a template from an image with `template.create({ name, fromImage })` and pass its name as `templateId`. Create a snapshot with `compute.snapshot.create(instanceId, { name: 'my-snapshot' })` — a name is required. Building a new template needs `fromImage` or `dockerfile` on `template.create`; pick an existing template with `templateId` on sandbox create.

### Configuration Options

```typescript
interface GravixLayerConfig {
  /** GravixLayer API key - if not provided, will use GRAVIXLAYER_API_KEY env var */
  apiKey?: string
  /** API base URL - if not provided, will use GRAVIXLAYER_BASE_URL env var */
  baseUrl?: string
  /** Default cloud - if not provided, will use GRAVIXLAYER_CLOUD env var */
  cloud?: string
  /** Default region - if not provided, will use GRAVIXLAYER_REGION env var */
  region?: string
  /** Request timeout in milliseconds */
  timeout?: number
  /** Retry budget. Defaults to 0 */
  maxRetries?: number
  /** Use HTTP/2. Defaults to true */
  http2?: boolean
}
```

| Option       | Environment variable   | Description                     |
| ------------ | ---------------------- | ------------------------------- |
| `apiKey`     | `GRAVIXLAYER_API_KEY`  | GravixLayer API key (required)  |
| `baseUrl`    | `GRAVIXLAYER_BASE_URL` | API origin                      |
| `cloud`      | `GRAVIXLAYER_CLOUD`    | Default cloud for placement     |
| `region`     | `GRAVIXLAYER_REGION`   | Default region for placement    |
| `timeout`    | —                      | Request timeout in milliseconds |
| `maxRetries` | —                      | Retry budget (default `0`)      |
| `http2`      | —                      | Use HTTP/2 (default `true`)     |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.computesdk.com/providers/gravixlayer.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
