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

# VNC Desktop

***Novita Desktop***  provides an isolated virtual desktop environment for building and testing Computer Use Agents. This solution provides a comprehensive, isolated desktop environment that enables AI agents to securely interact with desktop applications through controlled virtualization.  This guide explains how to run Novita Desktop on the Novita Sandbox service.

***

### 1. Get Novita API Key

### 2. Environment Configuration

Before you start using the service, you need to configure the necessary environment variables:

```bash CLI icon="terminal" theme={"system"}
export NOVITA_API_KEY=<Your API key obtained in the previous step>
```

### 3. SDK Installation

Select the appropriate installation method corresponding to your development environment and programming language:

```bash CLI icon="terminal" theme={"system"}
npm i novita_sandbox
```

```bash CLI icon="terminal" theme={"system"}
pip install novita_sandbox
```

### 4. Implementation Examples

#### Get Virtual Desktop Stream VNC URL

The following implementation demonstrates the instantiation of a virtual desktop environment and the retrieval of VNC access endpoints for remote desktop interaction:

```js JavaScript & TypeScript icon="js" theme={"system"}
// demo.ts implementation
import { Novita } from 'novita-sandbox'

async function main() {
  const novita = new Novita({ apiKey: process.env.NOVITA_API_KEY })

  // Initialize virtual desktop sandbox instance
  const desktop = await novita.desktop.create({ timeoutMs: 3_600_000 })

  // Activate desktop streaming service
  await desktop.stream.start()

  // Retrieve interactive VNC endpoint URL
  const url = desktop.stream.getUrl()
  console.log(url)

  // Expected output format:
  // Browser-accessible URL for interactive virtual desktop session. Suitable for application integration.
  // https://6080-ik0n7lc3j0dvqd4jxy6g7.us-phx-1.sandbox.novita.ai/vnc.html?autoconnect=true&resize=scale

  // Retrieve read-only VNC endpoint URL (interaction disabled)
  const urlDisabledInteraction = desktop.stream.getUrl({ viewOnly: true })
  console.log(urlDisabledInteraction)
  // Expected output format:
  // Browser-accessible URL for view-only virtual desktop session (non-interactive mode). Suitable for monitoring applications.
  // https://6080-ik0n7lc3j0dvqd4jxy6g7.us-phx-1.sandbox.novita.ai/vnc.html?autoconnect=true&view_only=true&resize=scale

  // Keep the program running
  console.log("Desktop stream started, press Ctrl+C to stop the program...")
  const interval = setInterval(() => {}, 1000)

  // Register interrupt signal handlers for resource cleanup
  let isCleaning = false
  const cleanup = async () => {
    if (isCleaning) return
    isCleaning = true

    console.log("\\nProgram interrupted, cleaning up resources...")
    clearInterval(interval)
    try {
      await desktop.stream.stop() // Terminate streaming service
      await desktop.kill()        // Deallocate sandbox instance
    } catch (err) {
      console.error("Error cleaning up resources:", err)
    }
    process.exit(0)
  }

  process.on('SIGINT', cleanup)
  process.on('SIGTERM', cleanup)
}

main().catch(console.error)
```

```python Python icon="python" theme={"system"}
# demo.py implementation
import os
import time

from novita_sandbox import Novita

novita = Novita(api_key=os.environ["NOVITA_API_KEY"])

# Initialize virtual desktop sandbox instance
desktop = novita.desktop.create(timeout=3600)

# Activate desktop streaming service
desktop.stream.start()

# Retrieve interactive VNC endpoint URL
url = desktop.stream.get_url()
print(url)
# Expected output format:
# Browser-accessible URL for interactive virtual desktop session. Suitable for application integration.
# https://6080-ik0n7lc3j0dvqd4jxy6g7.us-phx-1.sandbox.novita.ai/vnc.html?autoconnect=true&resize=scale

# Retrieve read-only VNC endpoint URL (interaction disabled)
url_readonly = desktop.stream.get_url(view_only=True)
print(url_readonly)
# Expected output format:
# Browser-accessible URL for view-only virtual desktop session (non-interactive mode). Suitable for monitoring applications.
# https://6080-ik0n7lc3j0dvqd4jxy6g7.us-phx-1.sandbox.novita.ai/vnc.html?autoconnect=true&view_only=true&resize=scale

# Implement keyboard interrupt handling for graceful shutdown
try:
    print("Desktop stream started, press Ctrl+C to stop the program...")
    while True:
        time.sleep(0.1)
except KeyboardInterrupt:
    print("\\nProgram interrupted, cleaning up resources...")

# Execute resource deallocation procedures
desktop.stream.stop()  # Terminate streaming service
desktop.kill()        # Deallocate sandbox instance
```

Running example:

![Integrations Desktop](https://mintcdn.com/novitaai/ORWoyuj5p0OZaN1D/images/sandbox/sandbox-integrations-desktop-1.png?fit=max\&auto=format\&n=ORWoyuj5p0OZaN1D\&q=85\&s=1352e9092252b38fcb79fadb98236e2d)

Access virtual desktop stream VNC URL:

![Integrations Desktop 2](https://mintcdn.com/novitaai/ORWoyuj5p0OZaN1D/images/sandbox/sandbox-integrations-desktop-2.png?fit=max\&auto=format\&n=ORWoyuj5p0OZaN1D\&q=85\&s=8127f3bf5b4cae9bd3b8ca4165bec339)


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