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

# Quick Start

> Get started with the GBOX SDK to create and manage virtual devices

## Installation

Install the GBOX SDK using your preferred package manager:

<CodeGroup>
  ```bash npm theme={null}
  npm install gbox-sdk
  ```

  ```bash pnpm theme={null}
  pnpm install gbox-sdk
  ```

  ```bash yarn theme={null}
  yarn add gbox-sdk
  ```
</CodeGroup>

## Basic Usage

### 1. Initialize the SDK

First, import and initialize the SDK with your API key for authentication:

<CodeGroup>
  ```typescript Basic Setup theme={null}
  import GboxSDK from "gbox-sdk";

  const gboxSDK = new GboxSDK({
    apiKey: process.env["GBOX_API_KEY"], // Recommended: use environment variables
  });
  ```

  ```typescript Full Configuration theme={null}
  import GboxSDK from "gbox-sdk";

  const gboxSDK = new GboxSDK({
    apiKey: process.env["GBOX_API_KEY"],
    baseURL: "https://gbox.ai/api/v1", // Optional: custom API base URL
    timeout: 60 * 1000, // Optional: request timeout in milliseconds
    maxRetries: 0, // Optional: maximum number of retries
  });
  ```
</CodeGroup>

### 2. Create Virtual Devices

Use the SDK to create different types of virtual devices:

<CodeGroup>
  ```typescript Android Device theme={null}
  async function createAndroidBox() {
    try {
      const box = await gboxSDK.create({
        type: "android",
        // Optional: add other configuration parameters
      });

      console.log("Android device created successfully:", box.id);
      return box;
    } catch (error) {
      console.error("Failed to create Android device:", error);
    }
  }

  createAndroidBox();
  ```

  ```typescript Linux Device theme={null}
  async function createLinuxBox() {
    try {
      const box = await gboxSDK.create({
        type: "linux",
      });

      console.log("Linux device created successfully:", box.id);
      return box;
    } catch (error) {
      console.error("Failed to create Linux device:", error);
    }
  }

  createLinuxBox();
  ```
</CodeGroup>

### 3. Complete Example

Here's a complete example showing how to create a device and perform basic operations:

```typescript theme={null}
import GboxSDK from "gbox-sdk";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"],
});

async function main() {
  try {
    // Create an Android device
    const box = await gboxSDK.create({ type: "android" });
    console.log(`Device created successfully, ID: ${box.id}`);

    // Start the device
    await gboxSDK.startBox({ id: box.id });
    console.log("Device started successfully");

    // Wait for device to be ready...

    // Stop the device
    await gboxSDK.stopBox({ id: box.id });
    console.log("Device stopped");
  } catch (error) {
    console.error("Operation failed:", error);
  }
}

main();
```

## Next Steps

* Learn how to [configure custom base URLs](/sdk/base-url)
* Understand [timeout settings](/sdk/timeout) and [retry mechanisms](/sdk/retries)
* Explore the complete [TypeScript SDK documentation <Icon icon="arrow-up-right" />](https://babelcloud.github.io/gbox-sdk-ts/classes/GboxSDK.html)
