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

# Erstellen Sie Ihre erste Agent Sandbox

## Konto erstellen

Wenn Sie noch kein Novita-Konto haben, <Link href="https://novita.ai/user/register" target="_blank">registrieren Sie sich</Link> zuerst. Weitere Informationen finden Sie im <Link href="/docs/de/guides/quickstart">Schnellstartleitfaden</Link>.

Neue Benutzer können eine kurze Umfrage zur Kontoeinrichtung abschließen, um kostenloses Sandbox-Guthaben im Wert von 100 \$ zu erhalten. Es ist keine Kreditkarte erforderlich.

## API-Schlüssel erstellen

Navigieren Sie zur Novita <Link href="https://novita.ai/settings/key-management" target="_blank">Schlüsselverwaltungsseite</Link>, erstellen Sie einen API-Schlüssel und speichern Sie den API-Schlüsselwert für die Verwendung in den folgenden Schritten.

## SDK installieren

Sie können das Novita SDK installieren, indem Sie die folgenden Befehle ausführen.

<CodeGroup isTerminalCommand>
  ```bash JavaScript & TypeScript SDK icon="terminal" theme={"system"}
  npm i novita-sandbox
  ```

  ```bash Python SDK icon="terminal" theme={"system"}
  pip install novita-sandbox
  ```
</CodeGroup>

## Umgebungsvariablen konfigurieren

Erstellen Sie eine `.env`-Datei in Ihrem Projektordner, falls sie nicht vorhanden ist, und konfigurieren Sie Ihren API-Schlüssel.

<Warning>
  Für JavaScript- und TypeScript-Projekte müssen Sie das Paket `dotenv/config` in Ihr Projekt importieren; für Python-Projekte müssen Sie die Bibliothek `dotenv` in Ihr Projekt importieren und die Methode `load_dotenv` aufrufen, um Umgebungsvariablen zu laden.
  Weitere Informationen finden Sie im [Beispiel](#use-sdk-to-start-agent-sandbox).
</Warning>

```bash .env icon="terminal" highlight={2} theme={"system"}
NOVITA_API_KEY=sk_*** # Novita API key obtained from previous steps
```

Alternativ können Sie den API-Schlüssel konfigurieren, indem Sie eine Umgebungsvariable in Ihrem Terminal setzen.

```bash Bash icon="terminal" highlight={2} theme={"system"}
export NOVITA_API_KEY=sk_*** # Novita API key obtained from previous steps
```

## SDK zum Starten der Agent Sandbox verwenden

Nachfolgend finden Sie ein einfaches Beispiel, das zeigt, wie Sie eine Sandbox erstellen, darin Code ausführen und Dateien im Sandbox-Dateisystem auflisten.

<CodeGroup>
  ```js JavaScript & TypeScript icon="js" theme={"system"}
  // index.ts
  import 'dotenv/config'
  import { Sandbox } from 'novita-sandbox/code-interpreter'

  // The .env file should be located in the project root directory
  // dotenv/config will automatically look for .env in the current working directory
  // Or 
  // You can set the environment variable in the command line
  // export NOVITA_API_KEY=sk_***

  async function main() {
    const sandbox = await Sandbox.create()
    try {
      const execution = await sandbox.runCode('print("hello world")')
      console.log(execution.logs)

      const files = await sandbox.files.list('/tmp')
      console.log(files)
    } finally {
      // Close sandbox when no longer needed
      await sandbox.kill()
    }
  }
  main().catch((err) => {
    console.error(err)
    process.exit(1)
  })

  ```

  ```python Python icon="python" theme={"system"}
  # main.py
  from dotenv import load_dotenv
  from novita_sandbox.code_interpreter import Sandbox


  # The .env file should be located in the project root directory
  # dotenv will automatically look for .env in the current working directory
  load_dotenv()

  # Or 
  # You can set the environment variable in the command line
  # export NOVITA_API_KEY=sk_***

  sandbox = Sandbox.create()
  execution = sandbox.run_code("print('hello world')")
  print(execution.logs)

  files = sandbox.files.list("/")
  print(files)

  # Close sandbox when no longer needed
  sandbox.kill()
  ```
</CodeGroup>

Führen Sie die folgenden Befehle aus, um den Code auszuführen.

<CodeGroup isTerminalCommand>
  ```bash index.ts icon="terminal" theme={"system"}
  npx tsx ./index.ts
  ```

  ```bash main.py icon="terminal" theme={"system"}
  python main.py
  ```
</CodeGroup>
