For example, the download file method is useful for downloading any files produced by LLM. You can let LLM generate and execute code inside the sandbox.
This LLM-generated code might produce some files like charts, CSV files, or PDF files that you want to download to your machine.
Copy
Ask AI
import { Sandbox } from 'e2b'import fs from 'node:fs'const sandbox = await Sandbox.create({ template: 'base' })const buffer = await sandbox.downloadFile('path/to/remote/file/inside/sandbox', 'buffer')// Save file to local filesystemfs.writeFileSync('path/to/local/file', buffer)await sandbox.close()