> ## 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.

# Créez votre premier Agent Sandbox

## Créer un compte

Si vous n’avez pas de compte Novita, <Link href="https://novita.ai/user/register" target="_blank">inscrivez-vous</Link> d’abord. Pour plus de détails, veuillez consulter le <Link href="/docs/fr/guides/quickstart">guide de démarrage rapide</Link>.

Les nouveaux utilisateurs peuvent répondre à un rapide questionnaire de configuration de compte pour obtenir 100 \$ de crédits Sandbox gratuits. Aucune carte bancaire n’est requise.

## Créer une clé API

Accédez à la <Link href="https://novita.ai/settings/key-management" target="_blank">page de gestion des clés</Link> Novita, créez une clé API et enregistrez la valeur de la clé API pour l’utiliser lors des étapes suivantes.

## Installer le SDK

Vous pouvez installer le SDK Novita en exécutant les commandes suivantes.

<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>

## Configurer les variables d’environnement

Créez un fichier `.env` dans le dossier de votre projet s’il n’existe pas, puis configurez votre clé API.

<Warning>
  Pour les projets JavaScript et TypeScript, vous devez importer le package `dotenv/config` dans votre projet ; pour les projets Python, vous devez importer la bibliothèque `dotenv` dans votre projet et appeler la méthode `load_dotenv` pour charger les variables d’environnement.
  Pour plus de détails, veuillez consulter l’[exemple](#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
```

Vous pouvez également configurer la clé API en définissant une variable d’environnement dans votre terminal.

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

## Utiliser le SDK pour démarrer un Agent Sandbox

Voici un exemple simple montrant comment créer un sandbox, y exécuter du code et lister les fichiers dans le système de fichiers du sandbox.

<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>

Exécutez les commandes suivantes pour lancer le code.

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

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